/*
FUCK IT.
*/
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
uint8_t arrow_up[8] = {
0b00000, //
0b00100, // 0
0b01110, // 000
0b11111, // 00000
0b00000, //
0b00000, //
0b00000, //
0b00000, //
};
uint8_t arrow_down[8] = {
0b00000, //
0b11111, //
0b01110, //
0b00100, //
0b00000, //
0b00000, //
0b00000, //
0b00000, //
};
String display = "Hello World : this is a message that i write by myself ",
list[] = {
"hello world",
"ujang bujangan",
"brohfashaoh",
"idk what i'm do. but its like fun. i think :)"
};
void setup() {
// put your setup code here, to run once:
lcd.init();
lcd.backlight();
lcd.createChar(3, arrow_up);
lcd.createChar(4, arrow_down);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
lcd.begin(16, 2);
display(list);
}
void action(int maxTime = 1000, int useMils = 10, ){
int timer = 0;
while(timer < maxTime){
for (int i = 2; i <= 4; i++){
if(digitalRead(i) == LOW) {
if(i == 2){
// up
}
else if (i == 3){
// down
}
else{
// ok
}
}
}
timer += useMils;
delay(useMils);
}
}
void display(String list[]) {
int textLength = display.length();
if (textLength > 16) {
for (int i = 0; i <= textLength - 16; i++) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(display.substring(i, i + 16));
lcd.setCursor(0, 1);
lcd.print("\x03 \x04 OK");
action(500, 10);
}
} else {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(display);
lcd.setCursor(0, 1);
lcd.print("\x03 \x04 OK");
action(1000, 10);
}
}
void loop(){
// hi
}