//https://eldontronics.wordpress.com/2018/02/11/lcd-module-connection-to-arduino-board-with-without-an-i2c-module/
/*
LiquidCrystal Library - Hello World
Dit voorbeeld is code uit het publieke domain.
http://www.arduino.cc/en/Tutorial/LiquidCrystalHelloWorld
Hoe werkt een 16x2 LCD scherm zonder i2c (elk blok op het display bestaat uit 5x8 pixels)
Je hebt als eerste een library nodig. De LiquidCrystal
library werkt met alle LCD schermen die compatible zijn met de
Hitachi HD44780 driver.
De aansluitingen:
* LCD RS pin to digital pin 12 (D12 op de nano)
* LCD Enable (E) pin to digital pin 11 (D11 op de nano)
* LCD D4 pin to digital pin 5 (D5 nano)
* LCD D5 pin to digital pin 4 (D4 nano)
* LCD D6 pin to digital pin 3 (D3 nano)
* LCD D7 pin to digital pin 2 (D2 nano)
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K weerstand potmeter: uitersten ground en +5V
* variabele (midden) to LCD VO pin (pin 3 van LCD)
Functies van deze library staan op:https://www.arduino.cc/reference/en/libraries/liquidcrystal/
*/
#include <LiquidCrystal.h> //library
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; //maak variabelen en koppel deze aan arduino pinnen
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // koppel de variabelen aan de lcd pinnen
byte smiley[8] = { // [8] means 8 rows (0-7)
B00000,
B10001,
B00000,
B00000,
B10001,
B01110,
B00000, //because this row is complete 0 you can skip this row
//B00000, //because this row is complete 0 you can skip this row
};
byte smiley2[8] = { // [8] means 8 rows (0-7)
B00000,
B10001,
B00100,
B00100,
B10001,
B01110,
B00000, //because this row is complete 0 you can skip this row
//B00000, //because this row is complete 0 you can skip this row
};
void setup() {
lcd.begin(16, 2); // start de LCD en geef aan hoeveel kolommen en rijen
lcd.print("hello, world!"); //print de boodschap op de LCD (1x want in de setup)
delay(500);
}
void loop() {
//count(); //execute void count(), including the hello world from void setup()
//lcd.clear();
//icon();
//scrollen();
//blink();
//cursor();
display();
}
void blink() {
// Turn off the blinking cursor:
lcd.noBlink();
delay(500);
// Turn on the blinking cursor:
lcd.blink();
delay(500);
}
void cursor() {
// Turn off the cursor:
lcd.noCursor();
delay(500);
// Turn on the cursor:
lcd.cursor();
delay(500);
}
void display() {
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
}
void count() {
lcd.setCursor(0,1); //zet de cursor op de eerste (0) positie op de tweede (1) rij
lcd.print(millis() / 1000); // print het aantal seconden (milliseconden gedeeld door 1000 = aantal seconden)
}
void icon() {
//lcd.clear();
lcd.begin(16, 2);
lcd.createChar(0, smiley2);
lcd.setCursor(5,1); //(position, row)
lcd.write(byte(0));
lcd.createChar(0, smiley);
lcd.setCursor(7,0); //(position, row)
lcd.write(byte(0));
}
void scrollen() {
lcd.setCursor(0, 1); // set the cursor to (0,1):
for (int i = 0; i < 10; i++) { // print from 0 to 9:
lcd.print(i);
delay(100);
}
delay(1000);
lcd.setCursor(0,1); // set the cursor to (0,1):
lcd.autoscroll(); // set the display to automatically scroll:
for (int thisChar = 0; thisChar < 11; thisChar++) { // print from 0 to 9:
lcd.print(thisChar);
delay(200);
}
lcd.noAutoscroll(); // turn off automatic scrolling
lcd.clear(); // clear screen for the next loop:
}
void scrol_text() {
lcd.clear();
lcd.setCursor(0, 0); // set the cursor to (0,0)
lcd.print("scrolling text ");
for (int i = 0; i < 10; i++) { // print from 0 to 9:
lcd.print(i);
delay(100);
}
delay(1000);
lcd.setCursor(0,1); // set the cursor to (0,1):
lcd.autoscroll(); // set the display to automatically scroll:
for (int thisChar = 0; thisChar < 11; thisChar++) { // print from 0 to 9:
lcd.print(thisChar);
delay(200);
}
lcd.noAutoscroll(); // turn off automatic scrolling
lcd.clear(); // clear screen for the next loop:
}