// 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);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}