Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.70 KB | None | 0 0
  1. /* TRASMETTITORE PROVA NRF24L01
  2.  */
  3. #include<SPI.h>
  4. #include<nRF24L01.h>
  5. #include<RF24.h>
  6.  
  7. const uint64_t pipe = 0xE8E8F0F0E1LL;
  8. #define CE D2
  9. #define CSN D8
  10. RF24 radio(CE, CSN);
  11.  
  12.  
  13. int pulsante = D4;
  14. int statopulsante;
  15. int datodainviare[2];
  16.  
  17. void setup(){
  18.       Serial.begin(9600);
  19.       pinMode(pulsante, INPUT_PULLUP);
  20.       radio.begin();
  21.       radio.openWritingPipe(pipe);
  22.  
  23.   }
  24. void loop(){
  25.  
  26.        statopulsante = digitalRead(pulsante);
  27.        Serial.println(statopulsante);
  28.        if(statopulsante == LOW){
  29.           datodainviare[0] = 1;
  30.         }
  31.         else{
  32.            datodainviare[0] = 0;
  33.           }
  34.        radio.write(&datodainviare, sizeof(datodainviare));
  35.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement