Lukas4186

Empfänger

Jan 25th, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.03 KB | None | 0 0
  1.  
  2. #include <LiquidCrystal.h>
  3. #include <SPI.h>
  4. #include <nRF24L01.h>
  5. #include <RF24.h>
  6.  
  7. #define CE_PIN   9
  8. #define CSN_PIN 10
  9. const uint64_t pipe = 0xE8E8F0F0E1LL;
  10. RF24 radio(CE_PIN, CSN_PIN);
  11. int entfernung[1];
  12.  
  13. LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
  14.  
  15. void setup() {
  16.   lcd.begin(16, 2);
  17.   Serial.begin(9600);
  18.   delay(1000);
  19.   radio.begin();
  20.   radio.openReadingPipe(1,pipe);
  21.   radio.startListening();;
  22. }
  23.  
  24. void loop()
  25. {
  26.   if ( radio.available() )
  27.   {
  28.     bool done = false;
  29.     while (!done)
  30.     {
  31.       done = radio.read( entfernung, sizeof(entfernung) );
  32.       Serial.print("Entfernung = ");
  33.       Serial.print(entfernung[1]);
  34.       lcd.clear();
  35.       lcd.setCursor(0, 0);
  36.       lcd.print("Entfernung = ");
  37.       lcd.print(entfernung[1]);
  38.       delay(1000);
  39.    
  40.     }
  41.   }
  42.       else
  43.       {
  44.       Serial.println("Kein Signal vorhanden");
  45.       lcd.clear();
  46.       lcd.setCursor(0, 0);
  47.       lcd.print("Kein Signal");
  48.       lcd.setCursor(0, 1);
  49.       lcd.print("vorhanden!");
  50.       delay(1000);
  51.       }
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment