Advertisement
Guest User

Untitled

a guest
Apr 18th, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Arduino.h"
  2. #include <RFM69.h>
  3. #include <SPI.h>
  4. #include <SPIFlash.h>
  5.  
  6.  
  7.  
  8. #define MYNODEID      1
  9. #define LED           0
  10. #define TONODEID      2
  11.  
  12. void setup() {
  13.  
  14. Serial.begin(9600);
  15. delay(8000);
  16. Serial.print(F("Node "));
  17. Serial.print(MYNODEID,DEC);
  18. Serial.println(F(" ready"));
  19. pinMode(LED, OUTPUT);
  20. }
  21.  
  22. void loop() {
  23.  
  24.   static char sendbuffer[62];
  25.   static int sendlength = 0;
  26.   char input = Serial.read();
  27.  
  28.       if (input != '\r') // not a carriage return checkt, dass nicht ohne Inhalt nur bei enter gesendet wird
  29.       {
  30.         sendbuffer[sendlength] = input;
  31.         sendlength++;
  32.       }
  33.  
  34.       // If the input is a carriage return, or the buffer is full:
  35.  
  36.       if ((input == '\r') || (sendlength == 61)) // CR or buffer full
  37.       {
  38.       Serial.print(F("sending to node "));
  39.       Serial.print(TONODEID, DEC);
  40.       Serial.print(F(", message ["));
  41.       for (byte i = 0; i < sendlength; i++) // was im buffer steht Hello World
  42.         Serial.print(sendbuffer[i]);
  43.       Serial.println(F("]"));
  44.       sendlength = 0; // reset the packet
  45.       digitalWrite(LED,HIGH);
  46.       Serial.println("LED on");
  47.       delay(500);
  48.       digitalWrite(LED,LOW);
  49.       Serial.println("LED off");
  50.       delay(500);
  51.       Serial.println(F("Cycle completed"));
  52.  
  53.   }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement