I am trying to write a script that has a button that turns on an LCD and displays "Please Wait". There is also another button that changes the text to "Access Granted". I can't figure out how to write the code for the second button. I think I have the on/off button working though. Can anyone help?
//first demo
/*
* RS: Pin 2
* EN: Pin 3
* D4: Pin 4
* D5: Pin 5
* D6: Pin 6
* D7: Pin 7
*/
//Pin Defs.
int pushButton = Pin 8
int pushButton2 = Pin 9
//start button Defs.
boolean lastButton = LOW;
boolean lcdOn = false;
boolean currentButton = LOW
//Change LCD Defs.
boolean lastButton2 = LOW;
boolean lcd2On = false;
boolean currentButton2 = LOW
//Include the LCD Library
#include <LiquidCrystal.h>
//Initialize an LCD object
LiquidCrystal lcd(2,3,4,5,6,7);
//Create Characters
byte p20[8] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
};
byte p40[8] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
};
byte p60[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
};
byte p80[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
};
byte p100[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};
void setup ()
{
//Start Button setup
pinMode(pushbutton, INPUT);
pinMode(lcd, OUTPUT);
boolean debounce(boolean last)
{
boolean current = digitalRead(pushButton);
if (last !=current)
{
delay(5);
current = digitalRead(pushButton);
}
return current;
}
//Change LCD display button
pinMode(pushbutton2, INPUT);
pinMode(lcd2, OUTPUT);
boolean debounce)(boolean last)
{
boolean current = digitalRead(pushButton2);
if (last !=current)
{
delay(5);
current = digitalRead(pushButton2);
}
return current;
}
//Begin the LCD interface
lcd.begin(16,2)
//Print my Name
lcd.print(" Please Wait ")
//Create Custom Characters
lcd.createChar(0, p20);
lcd.createChar(1, p40);
lcd.createChar(2, p60);
lcd.createChar(3, p80);
lcd.createChar(4, p100);
}
void loop ()
{
//Move the cursor
lcd.setCursor(0,1);
//Clear the line
lcd.print(" ");
//Loop through and make progress bar
for (int i = 0; i<16; i++)
{
for (int j = 0;j<5; j++)
{
lcd.setCursor(i,1);
lcd.write(j);
delay(100);
}
}
//starter button
currentButton = debounce(lastButton);
if (lastButton == LOW currentButton == HIGH)
{
lcdOn = !ledOn;
}
lastButton = currentButton;
digitalWrite(lcd, lcdOn);
//change LCD display
{currentButton = debounce(lastButton);
if (lastButton == LOW currentButton == HIGH)
{
lcd2On = !led2On;
}
lastButton = currentButton;
//Begin the LCD2 interface
lcd.begin(16,2)
//Print my second name
lcd.print(" Access Granted ")
//Create Custom Characters
lcd.createChar(0, p20);
lcd.createChar(1, p40);
lcd.createChar(2, p60);
lcd.createChar(3, p80);
lcd.createChar(4, p100);
}
}