/* Made by Jefferson Sandoval for the Embedded Networking and Communications assignment * during the FabAcademy2021 * * This code was made for testing my board for a remote control for my final project which is an * Omni-directional three-wheeler. * * Uploaded to an Arduino UNO board which, using a nRF24 module, serves as receiver reading data * from another board with 2 joysticks as input. After reading the received values, it prints on * Serial monitor a message that indicates the corresponding vehicle movements. * * Documentation: * http://fabacademy.org/2021/labs/kamplintfort/students/jefferson-sandoval/assignments/week14/ */ //Libraries for Communication part (nRF24) #include #include #include RF24 radio(7, 8); //Create radio object with and CE & CSN pins const byte address[6] = "00111"; //Receiver Communication address void setup() { Serial.begin(9600); //Begin Serial communication at 9600 bauds radio.begin(); //Initialize radio object radio.setPALevel(RF24_PA_LOW); //Set radio range radio.openReadingPipe(0, address); //Set address to transmitter radio.startListening(); //Set module as receiver } void loop() { int Values[3]; //Declare variable for data to receive if (radio.available()) { radio.read(&Values, sizeof(Values)); //Read array of Values from Transmitter //Print on Serial monitor a message according to the direction of movement of the joysticks if (Values[0]>=15){Serial.println("Forward");} if (Values[0]<=-15){Serial.println("Backward");} if (Values[1]>=15){Serial.println("Right");} if (Values[1]<=-15){Serial.println("Left");} if (Values[2]>=15){Serial.println("C-CW rotation");} if (Values[2]<=-15){Serial.println("CW rotation");} } delay(300); //Read values every 0.3 seconds }