Arduino Mega + LCD display

Video

Please click thumbnail image to start the video

Video on Arduino Mega + LCD display    iconSerial.png    volts33.png

Photo

Arduino Mega + LCD display
Arduino Mega + LCD display

Sketch

// Arduino Mega connected to LCD display
// Copyright (C) 2018 https://www.roboticboat.uk
// e3cf426b-a965-47db-b9f0-5d6a717ce6b6
//
// 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/>.
// These Terms shall be governed and construed in accordance with the laws of
// England and Wales, without regard to its conflict of law provisions
void setup()
{
Serial2.begin(9600);
}
void loop() {
// Clear the screen
clearLCD();
//Print text on each line
selectLineOne();
Serial2.print("Line One");
selectLineTwo();
Serial2.print("Line Two");
selectLineThree();
Serial2.print("Line Three");
selectLineFour();
Serial2.print("Line Four");
//Let the screen update
delay(500);
}
//SerialLCD Functions
void clearLCD()
{
Serial2.write(0xFE); //command flag
Serial2.write(0x01); //clear command.
}
void selectLineOne()
{
//puts the cursor at line 0 char 0.
Serial2.write(0xFE); //command flag
Serial2.write(128); //position
}
void selectLineTwo()
{
//puts the cursor at line 2 char 0.
Serial2.write(0xFE); //command flag
Serial2.write(192); //position
}
void selectLineThree()
{
//puts the cursor at line 3 char 0.
Serial2.write(0xFE); //command flag
Serial2.write(148); //position
}
void selectLineFour()
{
//puts the cursor at line 4 char 0.
Serial2.write(0xFE); //command flag
Serial2.write(212); //position
}
void backlightOn()
{
//turns on the backlight
Serial2.write(0x7C); //command flag for backlight stuff
Serial2.write(157); //light level.
}
void backlightOff()
{
//turns off the backlight
Serial2.write(0x7C); //command flag for backlight stuff
Serial2.write(128); //light level for off.
}
void backlight50()
{
//sets the backlight at 50% brightness
Serial2.write(0x7C); //command flag for backlight stuff
Serial2.write(143); //light level for off.
}
void serCommand()
{
//a general function to call the command flag for issuing all other commands
Serial2.write(0xFE);
}
RoboticBoat.uk