0% found this document useful (0 votes)
4 views1 page

Rec Iver

Uploaded by

Nifty Stocks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Rec Iver

Uploaded by

Nifty Stocks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

#include <SPI.

h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Servo.h>

RF24 radio(9, 10); // CE, CSN


const byte address[6] = "00001";

Servo steeringServo;
Servo esc;

void setup() {
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);
radio.setPALevel(RF24_PA_LOW);
radio.startListening();

steeringServo.attach(6);
esc.attach(5);

esc.writeMicroseconds(1000); // Arm ESC (depends on ESC type)


delay(2000);
}

void loop() {
int data[2];
if (radio.available()) {
radio.read(&data, sizeof(data));
int xVal = data[0]; // Steering
int yVal = data[1]; // Throttle

int angle = map(xVal, 0, 1023, 0, 180); // Servo angle


int speed = map(yVal, 0, 1023, 1000, 2000); // ESC PWM range

steeringServo.write(angle);
esc.writeMicroseconds(speed);
}
}

You might also like