Stap 4: Nu de toevoeging van LCD met arduino
* LCD RS pin naar digitale pin 12
* LCD inschakelen pin naar digitale pin 11
* LCD D4 pin naar digitale pin 5
* LCD D5 pin naar digitale pin 4
* LCD D6 pin naar digitale pin 3
* LCD D7 pin naar digitale pin 2
* LCD R/W pen op grond
* 10K Ohm weerstand:
* eindigt aan + 5V en ground
* wisser naar LCD VO pin (pin 3)
#include <SoftwareSerial.h> SoftwareSerial mySerial(1, 0); // 1-RX, 0-TX - #include <LiquidCrystal.h> int ch1 = A0; int ch2 = A1; int ch3 = A2; int ch4 = A3; LiquidCrystal lcd(12, 11, 5, 4, 3, 2);;//(rs, enable, d4, d5, d6, d7) void setup() { mySerial.begin(9600); pinMode(ch1, OUTPUT); pinMode(ch2, OUTPUT); pinMode(ch3, OUTPUT); pinMode(ch4, OUTPUT);lcd.begin(16, 2); } void loop() { char caracter = mySerial.read(); //--------------------------------ch1--------------------- if(caracter == 'A') { digitalWrite(ch1,HIGH); lcd.setCursor(0, 0); lcd.print("r1 ON");}if(caracter == 'a') { digitalWrite(ch1,LOW); lcd.setCursor(0, 0); lcd.print("r1 OFF"); } //---------------------------------ch1---------------------- //---------------------------------ch2--------------------- if(caracter == 'B') { digitalWrite(ch2,HIGH); lcd.setCursor(8, 0); lcd.print("r2 ON"); }if(caracter == 'b') { digitalWrite(ch2,LOW); lcd.setCursor(8, 0); lcd.print("r2 OFF"); } //---------------------------------ch2---------------------- //---------------------------------ch3--------------------- if(caracter == 'C') { digitalWrite(ch3,HIGH); lcd.setCursor(0, 1); lcd.print("r3 ON"); }if(caracter == 'c') { digitalWrite(ch3,LOW); lcd.setCursor(0, 1); lcd.print("r3 OFF"); } //---------------------------------ch3---------------------- //---------------------------------ch4--------------------- if(caracter == 'D') { digitalWrite(ch4,HIGH); lcd.setCursor(8, 1); lcd.print("r4 ON"); }if(caracter == 'd') { digitalWrite(ch4,LOW); lcd.setCursor(8, 1); lcd.print("r4 OFF"); } //---------------------------------ch4---------------------- delay(10); }