Here is the code I am having issues with ( I want to learn and understand why/what is happening with the display)
Basically most of the code came from Droneworkshop but I’ve had to heavily change it to get to work with my display and of course using platformio.
This line ALWAYS throws up an error at the i2c_addr?
//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE);
The code below is working BUT in the scrolling loop the characters re-appear at line 2 (the third line on the lcd screen?)
Please can anyone tutor me as to why?
/*
Title: Project to display Temperature on LCD Display with I2C Interface
Sensor: GYTMP102
Date: 03/11/2023
Version:01
Author: D. Calland (With help from more experienced contributors)
Anyone can use this code if they wish to!
*/
//Include Required Libraries
#include <Arduino.h> //Platformio inserted
#include <Wire.h> //Arduino Header File for I/O
#include <LiquidCrystal_I2C.h> //Find in Platformio Libraries gets appended to platformio.ini
//Define LCD Pinout associated with I2C board add on
int en=6, rw=5, rs=4, d4=11, d5=12, d6=13,d7=14, bl=15; //(really doesn't do anything to my display)
//Define I2C Address (I know its 0x27)
//#define i2c_addr = 0x27;
LiquidCrystal_I2C lcd(0x27,20,4); //(Only thing I've found that works)
//LiquidCrystal_I2C lcd(i2c_addr, en, rw, rs, d4, d5, d6, d7, bl, POSITIVE); Tried this and always threw up an error in not recognising i2c_addr
void setup() // put your setup code here, to run once:
{ //Set display type as 20 char, 4 rows
lcd.init();
lcd.backlight();
lcd.begin(20,4);
}
void loop()
{
while(1){ lcd.begin(20,4);
// put your main code here, to run repeatedly:
//Demo 1 - flash the backlight
lcd.setCursor(0,0);
lcd.print("Backlight Demo");
lcd.setCursor(0,1);
lcd.print("Flash 4 Times");
delay(2000);
lcd.clear();
//Flash 4 times counter
for (int i = 0; i < 4; i++)
{
lcd.backlight();
delay(500);
lcd.noBacklight();
delay(500);
}
//Turn backlight back on
lcd.backlight();
//Demo 2 - scroll
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Scroll demo -");
delay(500);
//Set the display to automatically scroll
lcd.autoscroll();
//Print from 0 to 9:
for (int thisChar = 0; thisChar < 10; thisChar++)
{
lcd.setCursor(0,0);
lcd.print(thisChar);
delay(2000);
}
lcd.clear();
//Turn off automatic scrolling
lcd.autoscroll();
delay(1000);
}
}