Lesson 19-1: Using an LCD Screen with Arduino
In this lecture, we learn how to use LCD screens, both 2-line and 4-line LCDs (LCD1602 and LCD2004). We first learn about the module, then we learn how to get the I2C address for the module, then we learn how to display text on both lines.
A counter example, which counts from 0, is shown. Then we learn how to measure the DC voltage from a variable resistor (or potentiometer).
554-Lesson 19: Arduino code to a text on LCD1602 and LCD2004 screen-1
Язык: C++
/*
* Robojax Arduino Step-by-Step Course
* Lesson 19-1 Introduction to LCD
* LCD1602-I2C or LCD2004-I2C
* This code has been modified from the Arduino library
Please watch video instructions 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
* Updated by Ahmad Shamshiri for Robojax on December 30, 2018 at 18:27
* in Ajax, Ontario, Canada
*
*
* 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 downloaded 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(0x3F, 16, 2);
int count =700;
void setup()
{
//Robojax Arduino Step-by-Step Course http://robojax.com/L/?id=338
// initialize the LCD,
lcd.begin();
// Turn on the backlight 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
//start of loop Robojax code for LCD with I2C
lcd.clear();
lcd.setCursor (0,0); // set cursor at line 0, char 0
lcd.print("Robojax");
lcd.setCursor (0,1); // go to start of 2nd line
lcd.print("Hello World!");
lcd.setCursor (13,1); // go to start of 2nd line
lcd.print(count);
delay(500);
count++;
//end of loopcode Robojax code for LCD with I2C
}
Ресурсы и ссылки
Ресурсов пока нет.
Файлы📁
Нет доступных файлов.