You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
945 B
40 lines
945 B
6 months ago
|
/*
|
||
|
* 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>
|
||
|
|
||
6 months ago
|
#define PROGRAM "RS485-Nano Rev 2.1 / Transceiver 1.0"
|
||
6 months ago
|
|
||
6 months ago
|
#define Max485_RO 2 // read-output of Max485
|
||
|
#define Max485_RE 8 // not-read-enable of Max485
|
||
|
#define Max485_DE 8 // data enable of Max485
|
||
|
#define Max485_DI 9 // data input of Max485
|
||
6 months ago
|
|
||
|
String message = "";
|
||
|
|
||
|
void setup() {
|
||
|
Serial.begin(115200);
|
||
|
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
if (available485()) {
|
||
|
Serial.println(get485message());
|
||
|
}
|
||
|
if (Serial.available()) {
|
||
|
// get the new byte:
|
||
|
char c = (char)Serial.read();
|
||
|
if (c == '\n') {
|
||
|
send485(message.c_str());
|
||
|
message = "";
|
||
|
} else {
|
||
|
message += c;
|
||
|
}
|
||
|
}
|
||
|
}
|