Equipment: Arduino UNO, Spark Fun LCD shield V.1.
Project Goals: Request users to input their name using the LCD shield buttons (up/down/left/right) and scroll through the letters with up and down. The name value is a variable length. Up/down should scroll through the alphabet, left and right should move the cursor, and select should save the value and default the value to all zero's.
The cursor should blink, (I have used the flashing block) but would prefer the flashing underscore (if possible).
When the user depresses the select button the value should be saved in the EEPROM. Reading some posts, this can be accomplished by converting each value to a decimal and save the value one byte (IE..if user puts the name COW in the LCD shield, C=67, O=79, W=87. I would like Byte 0=67 (C), Byte 1=79 (O) and Byte 2=87 (W). I am unclear how to do this part.
I have attached my code, this is a hobby for me, and I had been using Parallax before-please be kind ;D
#include <LiquidCrystal.h>
#include <EEPROM.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
int ans = 0;
int a = 0; //used for moving the cursor left or right.
int addr = 0;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Enter value:");
// Turn on the blinking cursor:
lcd.blink();
delay(3000);
}
void loop() {
int x;
x = analogRead (0); //read the button input value
lcd.setCursor(a,1); //variable 'a' set to 0 in the global setup
if (x < 60) {
//right button
a++;
ans = 0;
}
else if (x < 200) {
//up button
ans++;
lcd.print(ans);
}
else if (x < 400){
//down button
ans--;
lcd.print(ans);
}
else if (x < 600){
//left button
a--;
}
else if (x < 800){
//want to use this to save the value and move onto another function.
}
delay(200);
// write the value to the appropriate byte of the EEPROM.
// these values will remain there when the board is
// turned off.
EEPROM.write(0, a);
}