// NRF24L01 Module Tutorial - Code for Receiver using Arduino UNO //Include needed Libraries at beginning #include "nRF24L01.h" #include "RF24.h" #include "SPI.h" #include "Servo.h" Servo MyServo; //Object RF24 radio(9,10); // NRF24L01 used SPI pins + Pin 9 and 10 on the UNO const uint64_t pipe = 0xE6E6E6E6E6E6; // Needs to be the same for communicating between 2 NRF24L01 void setup(void){ Serial.begin(9600); //DC motor and servo pinMode(3,OUTPUT);//DC pinMode(0,OUTPUT);//DC direction pinMode(6,OUTPUT);//Servo myservo.attach(6) radio.begin(); // Start the NRF24L01 radio.openReadingPipe(1,pipe); // Get NRF24L01 ready to receive radio.setPayloadSize(32); radio.startListening(); // Listen to see if information received } void loop(void){ //Serial.println("Alive"); while (radio.available()) //signal security { float PWM1; float PWM2; float ReceivedMessage[3]={111}; radio.read(&ReceivedMessage, sizeof(ReceivedMessage)); // Read information from the NRF24L01 Serial.println(ReceivedMessage[0]); //X Serial.println(ReceivedMessage[1]); //Y Serial.println(ReceivedMessage[2]); //button Serial.println("up"); //DC contorl if(ReceivedMessage[1]<512)//DC direction { digitalWrite(0,LOW); Serial.println(foward); } else { digitalWrite(0,HIGH); Serial.println(backward); } PWM1=ReceivedMessage[0]*0,24-122,88 PWM1=abs(PWM1);//DC speed value analogWrite(3, PWM1); //Servo control PWM2=ReceivedMessage[1]*180/1024; myservo.write(PWM2); } delay(100); }