Merge branch 'nano-revision-2.1' into nano-revision-2.2
This commit is contained in:
@@ -18,11 +18,12 @@
|
||||
#define Max485_DI 9 // data input of Max485
|
||||
|
||||
#define TRESHOLD 1024
|
||||
#define ID 0
|
||||
#define ID 4
|
||||
// 0=Test
|
||||
// 1=Arbeitszimmer
|
||||
// 2=Küche
|
||||
// 3=Bad
|
||||
// 4=Treppenhaus
|
||||
|
||||
//#define LOG_TO_SERIAL
|
||||
#define SEND_485
|
||||
|
||||
38
Software/SerialTransceiver/SerialTransceiver.ino
Normal file
38
Software/SerialTransceiver/SerialTransceiver.ino
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Demonstrates how to use LCDisplay in conjunction with SoftRS485:
|
||||
*
|
||||
* The main _loop_ of this program listens on the RS485 bus.
|
||||
* Whenever a message is received from the bus, it is displayed on the LCD.
|
||||
*/
|
||||
|
||||
// include the library code:
|
||||
#include <SoftRS485.h>
|
||||
|
||||
|
||||
#define Max485_RO 2 // read-output of Max485
|
||||
#define Max485_RE 3 // not-read-enable of Max485
|
||||
#define Max485_DE 8 // data enable of Max485
|
||||
#define Max485_DI 9 // data input of Max485
|
||||
|
||||
#define PROGRAM "{hw:RS485-Nano rev 2.1,firmware:Transceiver,version:1.0}"
|
||||
|
||||
String message = "";
|
||||
char c;
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
|
||||
send485(PROGRAM);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (available485()) Serial.println(get485message());
|
||||
while (Serial.available()) {
|
||||
c = (char)Serial.read();
|
||||
if (c == '\n') {
|
||||
send485(message.c_str());
|
||||
message = "";
|
||||
} else {
|
||||
message += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user