Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2020
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Vibration Analysis Monitoring */
  2.  
  3. #include <SPI.h>
  4. #include <nRF24L01.h>
  5. #include <RF24.h>
  6. RF24 radio(53, 48); // CE, CSN
  7. const byte address[6] = "00010";
  8. int r = 0;
  9. void setup() {
  10.   radio.begin();
  11.   radio.openWritingPipe(address);
  12.   radio.setPALevel(RF24_PA_MIN);
  13.   radio.stopListening();
  14.   Serial.begin(9600);
  15. }
  16.  
  17. void loop() {
  18.  
  19.   if(Serial.available()){        
  20.     r = Serial.read();
  21.     //Serial.println(r);  
  22.    
  23.       }
  24.  if ( r == 49){                                 // 49 is the decimal equivalent of the ASCII char 1 which the RPi sends
  25.       const char text1[] = "2OK";
  26.       delay(100);  
  27.       radio.write(&text1, sizeof(text1));
  28.      
  29.     }
  30.  if ( r == 50){                                 // 50 is the decimal equivalent of the ASCII char 2 which the RPi sends
  31.       const char text2[] = "2WE";
  32.       delay(100);  
  33.       radio.write(&text2, sizeof(text2));
  34.      
  35.      }
  36.  if ( r == 51){                                 // 51 is the decimal equivalent of the ASCII char 3 which the RPi sends
  37.       const char text3[] = "2NO";
  38.       delay(100);  
  39.       radio.write(&text3, sizeof(text3));
  40.      
  41.     }    
  42.  if ( r == 52){                                 // 52 is the decimal equivalent of the ASCII char 4 which the RPi sends
  43.       const char text4[] = "2LE";
  44.       delay(100);  
  45.       radio.write(&text4, sizeof(text4));
  46.      
  47.     }
  48.  if ( r == 53){                                 // 53 is the decimal equivalent of the ASCII char 5 which the RPi sends
  49.       const char text5[] = "2ER";
  50.       delay(100);  
  51.       radio.write(&text5, sizeof(text5));
  52.      
  53.     }    
  54.   delay(1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement