Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Vibration Analysis Monitoring */
- #include <SPI.h>
- #include <nRF24L01.h>
- #include <RF24.h>
- RF24 radio(53, 48); // CE, CSN
- const byte address[6] = "00010";
- int r = 0;
- void setup() {
- radio.begin();
- radio.openWritingPipe(address);
- radio.setPALevel(RF24_PA_MIN);
- radio.stopListening();
- Serial.begin(9600);
- }
- void loop() {
- if(Serial.available()){
- r = Serial.read();
- //Serial.println(r);
- }
- if ( r == 49){ // 49 is the decimal equivalent of the ASCII char 1 which the RPi sends
- const char text1[] = "2OK";
- delay(100);
- radio.write(&text1, sizeof(text1));
- }
- if ( r == 50){ // 50 is the decimal equivalent of the ASCII char 2 which the RPi sends
- const char text2[] = "2WE";
- delay(100);
- radio.write(&text2, sizeof(text2));
- }
- if ( r == 51){ // 51 is the decimal equivalent of the ASCII char 3 which the RPi sends
- const char text3[] = "2NO";
- delay(100);
- radio.write(&text3, sizeof(text3));
- }
- if ( r == 52){ // 52 is the decimal equivalent of the ASCII char 4 which the RPi sends
- const char text4[] = "2LE";
- delay(100);
- radio.write(&text4, sizeof(text4));
- }
- if ( r == 53){ // 53 is the decimal equivalent of the ASCII char 5 which the RPi sends
- const char text5[] = "2ER";
- delay(100);
- radio.write(&text5, sizeof(text5));
- }
- delay(1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement