Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Arduino.h"
- #include <RFM69.h>
- #include <SPI.h>
- #include <SPIFlash.h>
- #define MYNODEID 1
- #define LED 0
- #define TONODEID 2
- void setup() {
- Serial.begin(9600);
- delay(8000);
- Serial.print(F("Node "));
- Serial.print(MYNODEID,DEC);
- Serial.println(F(" ready"));
- pinMode(LED, OUTPUT);
- }
- void loop() {
- static char sendbuffer[62];
- static int sendlength = 0;
- char input = Serial.read();
- if (input != '\r') // not a carriage return checkt, dass nicht ohne Inhalt nur bei enter gesendet wird
- {
- sendbuffer[sendlength] = input;
- sendlength++;
- }
- // If the input is a carriage return, or the buffer is full:
- if ((input == '\r') || (sendlength == 61)) // CR or buffer full
- {
- Serial.print(F("sending to node "));
- Serial.print(TONODEID, DEC);
- Serial.print(F(", message ["));
- for (byte i = 0; i < sendlength; i++) // was im buffer steht Hello World
- Serial.print(sendbuffer[i]);
- Serial.println(F("]"));
- sendlength = 0; // reset the packet
- digitalWrite(LED,HIGH);
- Serial.println("LED on");
- delay(500);
- digitalWrite(LED,LOW);
- Serial.println("LED off");
- delay(500);
- Serial.println(F("Cycle completed"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement