/* 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 my board which, using a nRF24 module and two joysticks, serves as transmitter * sending data to an Arduino UNO board. * * Documentation: * http://fabacademy.org/2021/labs/kamplintfort/students/jefferson-sandoval/assignments/week14/ */ //Libraries for Communication part (nRF24) #include #include #include RF24 radio(4, 5); //Create radio object with and CE & CSN pins const byte address[6] = "00111"; //Transmitter communication address void setup() { radio.begin(); //Initialize radio object radio.setPALevel(RF24_PA_LOW); //Set radio range radio.openWritingPipe(address); //Set address to receiver radio.stopListening(); //Set module as transmitter } void loop() { int Values[3]; ////Declare variable for data to send //Read values from Joysticks and convert them to percentage. //I used 200 cause the joystick can rotate only 50% on any direction. Values[0] = map(analogRead(0),0,1023,-200,200); //Left and Right movement from Joystick_1 Values[1] = map(analogRead(1),0,1023,-200,200); //Forward and Backward movement from Joystick_1 Values[2] = map(analogRead(7),0,1023,-200,200); //Rotation movement from Joystick_2 radio.write(&Values, sizeof(Values)); //Send array of Values to Receiver delay(300); //Send values every 0.3 seconds }