Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- #define CE_PIN 9
- #define CSN_PIN 10
- #define JOYSTICK_X A0
- #define JOYSTICK_Y A1
- #define JOYSTICK_Z A2
- const uint64_t pipe = 0xE8E8F0F0E1LL;
- RF24 radio(CE_PIN, CSN_PIN);
- int joystick[4];
- void setup()
- {
- Serial.begin(9600);
- radio.begin();
- radio.openWritingPipe(pipe);
- pinMode(2, INPUT);
- digitalWrite(2, HIGH);
- }
- void loop()
- {
- joystick[0] = analogRead(JOYSTICK_X);
- joystick[0] = map(joystick[0],0,1023,1,180);
- joystick[1] = analogRead(JOYSTICK_Y);
- joystick[2] = analogRead(JOYSTICK_Z);
- joystick[2] = map(joystick[2],0,1023,1,180);
- joystick[3] = digitalRead(2);
- radio.write( joystick, sizeof(joystick) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement