- Lesson 19-1: Using LCD Screen with Arduino.
- Lesson 19-2: Measuring voltage from pot and displaying on screen
Related or required files and link to this lesson
Please select other codes for this lecture from the links below.
Related or required files and link to this lesson
In this lecture we learn how to use LCD screen both 2 line and 4 lines LCD LCD1602 and LCD2004. We first learn about the module, then we learn
how to get the I2C addesss for the module, then we lean how to dispaly text on both lines.
A counter example which counts from 0 is shown. Then we learn how to measur the DC voltage from
a variable resistor (or potentiometer).
/*
* Robojax Arduino Step By Step Course
* Introduction to LCD
* Lesson 19-2 Potentiometer on LCD1602
* This code has been modefied from the Arduino library
Please watch video instruction here https://youtu.be/pxUjEsJQW2M
This code is available at http://robojax.com/course1/?vid=lecture11
with over 100 lectures Free On YouTube Watch it here http://robojax.com/L/?id=338
Get the code for the course: http://robojax.com/L/?id=339
* Updted by Ahmad Shamshiri for Robojax on Dec 26, 2018
* in Ajax, Ontario, Canada
* com
*
* This is code for LCD1602 Display with I2C module
* which can display text on the screen.
*
* This code is "AS IS" without warranty or liability. Free to be used as long as you keep this note intact.*
* This code has been download from Robojax.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 or 20 chars and 2 or 4 lines display
LiquidCrystal_I2C lcd(0x27, 16, 2);
int count =700;
void setup()
{
//Robojax Arduino Step By Step Course http://robojax.com/L/?id=338
// Robojax code for LCD with I2C
// initialize the LCD,
lcd.begin();
// Turn on the blacklight and print a message.
lcd.backlight();
// Robojax code for LCD with I2C
}
void loop()
{
//Robojax Arduino Step By Step Course http://robojax.com/L/?id=338
int potValue = analogRead(A0);
float voltage = potValue * (5.0 / 1023.0);
//start of loop Robojax code for LCD with I2C
lcd.clear();
lcd.print("LCD1602 Tutorial");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("Voltage:");
lcd.setCursor (9,1); // set to line 2 char 9
lcd.print(voltage);
lcd.setCursor (13,1); // set to line 2 char 14
lcd.print("V");
//lcd.setCursor (3,3); // set to line 4 character 4
//lcd.print("Text in line 4");
delay(1000);
count++;
//end of loopcode Robojax code for LCD with I2C
}