/* * Receiver Code * * by Marcello Tania * * Library: TMRh20/RF24, https://github.com/tmrh20/RF24/ * Power up the ESC by turning on the power supply (15.2-16V), */ #include //#include #include #include Servo esc; RF24 radio(7, 8); // CE, CSN const byte address[6] = "00001"; void setup() { Serial.begin(9600); //esc signal pinout esc.attach(3); radio.begin(); radio.openReadingPipe(0, address); radio.setPALevel(RF24_PA_MIN); radio.startListening(); //indicator that the microcontroller is on pinMode(13, OUTPUT); digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) Serial.println("Initializing ESC"); //initializing the esc esc.write(1023); delay(2000); Serial.println("You should hear a beeping sound "); esc.write(534); delay(2000); esc.write(53); Serial.println("The ESC will play a tone. "); Serial.println("Reciever is ready"); } void loop() { if (radio.available()) { int potentiometer; radio.read(&potentiometer, sizeof(potentiometer)); potentiometer =potentiometer- 230; potentiometer = map(potentiometer, 0, 1023, 0, 179); //290 is stop Serial.println(potentiometer); esc.write(potentiometer); } }