Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

Arduino HD44780 code button control - C Code Bank


Arduino HD44780 code button control
Display text on a LCD via an arduino (seeduino 328)
                /*
*Title: hd44870 lcd button control
*Date: 27-11-2009
*Author: Wolfmankurd
*Circuit:
*4bit mode, 11-14 to d2-d5 11,12 to enable r/w
*check arduino lcdcrystal exmaples for circuit diagrams.
*d8,9,10 buttons (make sure to have pull down resisitors.
**/

#include <LiquidCrystal.h>

const int debounce = 500; //change to taste.
const int rows = 4;
const int cols = 20;
int x,y,letter;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  lcd.begin(rows, cols);
  lcd.cursor();
  letter=' ';
}
void loop()
{
  if(button(8)){
    cursorMove(); 
    letter=' ';
  }
  if(button(9)){
    switch (letter){
      case ' ':
        letter='A';
        break;
      case 'Z':
        letter='a';
        break;
      case 'z':
        letter=' ';
        break;
      default:
        letter++;
    }
    lcdPrint();
  }
  if(button(10)){
    switch (letter){
      case ' ':
        letter='z';
        break;
      case 'a':
        letter='Z';
        break;
      case 'A':
        letter=' ';
        break;
      default:
        letter--;
    }
    lcdPrint();
  }
  delay(debounce);
}

void lcdPrint()
{
  lcd.print(letter,BYTE);
  lcd.setCursor(x,y); 
  return;
}

void cursorMove()
{
   if(x==cols){
    x=0;
    y++; 
  }
  if(y==rows){
    y=0;
    x=0;
  }
  lcd.setCursor(++x,y);
  return;
}

boolean button(int pin)
{
 if(digitalRead(pin)==HIGH){
  return true;
 }
return false; 
}
            
Comments
Sorry but there are no comments to display