/**
Arduino Calculator
Copyright (C) 2020, Uri Shaked.
Released under the MIT License.
https://forum.arduino.cc/t/inconsistent-behaviour-with-custom-chars-in-liquidcrystal/1330537/19
2024-12-13 by noiasca
code in thread
*/
#include <LiquidCrystal.h>
#include "icons.h"
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 7, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int counter = 0;
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
pinMode(6, OUTPUT); // Turn on LCD backlight
analogWrite(6, 255);
}
void loop() {
lcd.setCursor(6, 0);
lcd.print(counter);
lcd.setCursor(3, 0);
if(counter > 1) {
swapIcon(0);
}
lcd.write(byte(0));
delay(500);
swapIcon(1);
lcd.write(byte(0));
delay(500);
counter += 1;
}
void swapIcon(int icon){
byte icon_buf[8];
memcpy_P(icon_buf, icon_lookup[icon], 8);
//Serial.println(icon_buf[0], BIN);
lcd.createChar(0, icon_buf);
}
//