Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // A demonstration of this project can be found here: https://bit.ly/2Ynx09x
- /*
- Parts used for the remote:
- [1] joystick module
- [1] standard push button
- [1] Arduino Nano
- [1] 9v battery
- [1] power switch
- [1] NRF24L01 module
- [20+] jumper wires
- */
- #include <nRF24L01.h>
- #include <printf.h>
- #include <RF24.h>
- #include <RF24_config.h>
- #include <SPI.h>
- #define X_JOY A4
- #define Y_JOY A3
- RF24 radio(7,8); // ce, cs
- const byte address[6] = "111111";
- int button = 4;
- int States[3];
- void setup()
- {
- radio.begin();
- radio.openWritingPipe(address);
- radio.setPALevel(RF24_PA_HIGH);
- pinMode(X_JOY, INPUT);
- pinMode(Y_JOY, INPUT);
- pinMode(button, INPUT_PULLUP);
- }
- void loop()
- {
- delay(5);
- radio.stopListening();
- States[0] = analogRead(X_JOY);
- States[1] = analogRead(Y_JOY);
- States[2] = digitalRead(button);
- radio.write(&States, sizeof(States));
- }
Add Comment
Please, Sign In to add comment