Initialer Commit:
Es gibt einen Sender und einen Empfänger, die miteinander reden können. Das Senden geschieht im Moment noch ohne Kollisions-Überwachung. Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
19
Receiver/Receiver.ino
Normal file
19
Receiver/Receiver.ino
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#include <SoftwareSerial.h>
|
||||||
|
|
||||||
|
int baud = 19200;
|
||||||
|
int sTx = 4;
|
||||||
|
int sRx = 5;
|
||||||
|
SoftwareSerial mySerial(sRx,sTx);
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
Serial.begin(115200);
|
||||||
|
mySerial.begin(baud);
|
||||||
|
Serial.println("Receiver ready");
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
if (mySerial.available() > 0){
|
||||||
|
char c = mySerial.read();
|
||||||
|
Serial.print(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Sender/Sender.ino
Normal file
24
Sender/Sender.ino
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
int id = 0;
|
||||||
|
int baud = 19200;
|
||||||
|
int enable = 2;
|
||||||
|
|
||||||
|
void setup(){
|
||||||
|
pinMode(A0,INPUT);
|
||||||
|
id = analogRead(A0)*10;
|
||||||
|
pinMode(enable,OUTPUT);
|
||||||
|
Serial.begin(baud);
|
||||||
|
Serial.print("Baud rate set to ");
|
||||||
|
Serial.println(baud);
|
||||||
|
Serial.print("Initialized #");
|
||||||
|
Serial.println(id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
delay(id);
|
||||||
|
digitalWrite(enable,HIGH);
|
||||||
|
Serial.write("Howdy, this is Arduino #");
|
||||||
|
Serial.println(id);
|
||||||
|
Serial.flush();
|
||||||
|
digitalWrite(enable,LOW);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user