Project tutorial
LCD Button Writer

LCD Button Writer © GPL3+

Use buttons to type on LCD screen.

  • 748 views
  • 0 comments
  • 1 respect

Components and supplies

About this project

As my first Arduino project, I wanted to learn how to work with buttons, LCD, and LEDs.

So my project is pretty simple, you can type letters to LCD screen with buttons, move to next pixel and reset screen.

So first button, changes the letters. Second on moves to next space and the third reset the display.

Code

LcdbuttonsArduino
You need the LiquidCrystal_I2C to be able to run it. Download it from here https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
//Include the LCD Library.
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

const int buttonPin1 = 2;     // Charachter change button
const int buttonPin2 = 3;     // Move button
const int buttonPin3 = 4;     // Reset screen button
const int ledPin1 =  13;      // Charachter change LED pin
const int ledPin2 =  12;      // Move LED pin
const int ledPin3 =  11;      // Reset LED pin
const char chars[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','O','P','Q','R','S','U','V','W','X','Y','Z','.',',','1','2','3','4','5','6','7','8','9','0','-','*','@'};//add any additional characters

int charindex = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int charsSize = 0;
int cx = 0;
int cy = 0;



void setup() {
	//init LCD
  lcd.begin();
  lcd.clear();
	lcd.setCursor(0, 0);
  lcd.blink();  
	//Charachters array size
  charsSize = sizeof(chars);
  //LED init
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);
  pinMode(buttonPin3, INPUT);
  
}

void loop() {
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  buttonState3 = digitalRead(buttonPin3);
  //
  if (buttonState1 == HIGH) {
    if(charindex == charsSize){
      charindex = 0;
    }
    // change char and turn led on:
    digitalWrite(ledPin1, HIGH);
    lcd.print(chars[charindex]);
    lcd.setCursor(cx, cy);
    charindex++;
  } else {
    digitalWrite(ledPin1, LOW);
  }
  //Move to next pixel
  if (buttonState2 == HIGH) {
    digitalWrite(ledPin2, HIGH);
    charindex = 0;
    cx++;
    if(cx == 16){
      cx = 0;
      cy++;
    }
    if(cy == 2){
      cy = 0;
    }
    lcd.setCursor(cx, cy);
  }else {
    digitalWrite(ledPin2, LOW);
  }
  //reset
  if (buttonState3 == HIGH) {
    digitalWrite(ledPin3, HIGH);
    charindex = 0;
    cx = 0;
    cy = 0;
    lcd.setCursor(cx, cy);
    lcd.clear();
  }else {
    digitalWrite(ledPin3, LOW);
  } 
  delay(170);
}

Schematics

type letters to I2C screen with push buttons
Lcdbuttons1 bb icjuaqaxvd
type letters to I2C screen with push buttons
lcdbuttons1_WryaZFbUei.fzz

Comments

Similar projects you might like

You've Been Using a Button Wrong this Whole Time

Project tutorial by SMM2

  • 9,410 views
  • 1 comment
  • 6 respects

Push Button Combination Lock Using Arduino

Project tutorial by Asim Zulfiqar and High Voltages

  • 9,171 views
  • 10 comments
  • 28 respects

Temperature Monitor with DHT22 and I2C 16x2 LCD

Project tutorial by adrakhmat

  • 7,021 views
  • 5 comments
  • 22 respects

AI LCD friend!

Project tutorial by aip06

  • 5,593 views
  • 8 comments
  • 8 respects

Arduino - Use Reset Button Like a Push Button

by RoHa

  • 5,507 views
  • 0 comments
  • 13 respects

LCD (Liquid Crystal Display)

by MicroBob

  • 51,599 views
  • 68 comments
  • 158 respects
Add projectSign up / Login