adopted software to Nano 2.0
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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 <LiquidCrystal.h>
|
||||
#include <SoftRS485.h>
|
||||
|
||||
#define PROGRAM "RS485-Nano Rev 2.0 / LCDReceive 1.2"
|
||||
|
||||
#define Max485_RO 3 // read-output of Max485
|
||||
#define Max485_RE 5 // not-read-enable of Max485
|
||||
#define Max485_DE 9 // data enable of Max485
|
||||
#define Max485_DI 8 // data input of Max485
|
||||
|
||||
#define LCD_RS 4
|
||||
#define LCD_EN 6
|
||||
#define LCD_D4 7
|
||||
#define LCD_D5 11
|
||||
#define LCD_D6 12
|
||||
#define LCD_D7 13
|
||||
|
||||
|
||||
|
||||
// initialize the library by associating any needed LCD interface pin with the arduino pin number it is connected to
|
||||
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
init485(Max485_RO,Max485_RE,Max485_DE,Max485_DI); // library initialization:
|
||||
invert485polarity(true);
|
||||
// set up the LCD's number of columns and rows:
|
||||
lcd.begin(16, 2);
|
||||
// Print a message to the LCD.
|
||||
Serial.println(PROGRAM);
|
||||
lcd.print(PROGRAM);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (available485()) {
|
||||
String s = get485message();
|
||||
Serial.println(s);
|
||||
lcd.clear();
|
||||
lcd.setCursor(0, 0);
|
||||
lcd.print(s);
|
||||
if (s.length()>16) {
|
||||
lcd.setCursor(0, 1);
|
||||
s=s.substring(16);
|
||||
s.trim();
|
||||
lcd.print(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user