Advertisement
dberweger

receptor

Sep 6th, 2020 (edited)
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Servo.h>
  2. #include <SPI.h>
  3. #include <nRF24L01.h>
  4. #include <RF24.h>
  5.  
  6. RF24 radio(7, 8);
  7.  
  8. Servo rightFlap;
  9. Servo leftFlap;
  10. Servo motor;
  11. Servo back;
  12.  
  13. int motorSpeed;
  14. int flapL;
  15. int flapR;
  16. int flapBack;
  17.  
  18. int transmit[4];
  19.  
  20. const byte address[6] = "00001";
  21.  
  22. void setup() {
  23.   Serial.begin(9600);
  24.   rightFlap.attach(5);
  25.   leftFlap.attach(4);
  26.   motor.attach(8, 1000, 2000);
  27.   back.attach(3);
  28.  
  29.   radio.begin();
  30.   radio.openReadingPipe(0, address);
  31.   radio.setPALevel(RF24_PA_MAX);
  32.   radio.setDataRate(RF24_1MBPS);
  33.   radio.startListening();
  34. }
  35.  
  36. void loop() {
  37.   if (radio.available()) {
  38.     radio.read(&transmit, sizeof(transmit));
  39.     motorSpeed = transmit[0];
  40.     flapL = transmit[1];
  41.     flapR = transmit[2];
  42.     flapBack = transmit[3];
  43.    
  44.     Serial.println(transmit[1]);
  45.     Serial.println(receve[1]);
  46.     Serial.println(receve[2]);
  47.     Serial.println(receve[3]);
  48.    
  49.   }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement