LCD menu options (best route)
hi,
i have been searching internet 2 solid days idea of how menu options lcd. have included flow chart of trying accomplish. new programming, learning go. have included code have written far , tried make notations of , trying do. far have 1 button doing sort of after. still long way off though afraid.
the program choose led , options led light drum when struck through midi input. of midi stuff has been programmed else , trying interact 16x2 lcd (4 bit) it.
it have 5 buttons. up, down, right, left , center (store). don't think on right path buttons , accessing menu options, if of has advice sure use help.
thanks
jeremy
here completed schematic. still have tweaking on it.

i have been searching internet 2 solid days idea of how menu options lcd. have included flow chart of trying accomplish. new programming, learning go. have included code have written far , tried make notations of , trying do. far have 1 button doing sort of after. still long way off though afraid.
the program choose led , options led light drum when struck through midi input. of midi stuff has been programmed else , trying interact 16x2 lcd (4 bit) it.
it have 5 buttons. up, down, right, left , center (store). don't think on right path buttons , accessing menu options, if of has advice sure use help.
thanks
jeremy
here completed schematic. still have tweaking on it.
code: [select]
/*
lcd portion of code. sets pins
, intro screen.
the circuit:
* lcd rs pin digital pin 2
* lcd enable pin digital pin 3
* lcd d4 pin digital pin 4
* lcd d5 pin digital pin 5
* lcd d6 pin digital pin 6
* lcd d7 pin digital pin 7
* 10k resistor:
* ends +5v , ground
* wiper lcd vo pin (pin 3)
http://www.arduino.cc/en/tutorial/liquidcrystal
*/
// include library code:
#include <liquidcrystal.h>
// initialize 4 bit lcd library numbers of interface pins
liquidcrystal lcd(2, 3, 4, 5, 6, 7);
// constants won't change. they're used here
// set pin numbers:
const int ledpin = 13; // number of led pin
int switchpin1 =12; // switch1 connected pin 12
int switchpin2 =11; // switch2 connected pin 11
int switchpin3 =10; // switch3 connected pin 10
int switchpin4 =9; // switch4 connected pin 9
int switchpin5 =8; // switch5 connected pin 8
int led1pin = 13;
int led2pin = 8;
int led3pin = 9;
int led4pin = 10;
int led5pin = 12;
int val; // variable reading pin status
int val2; // variable reading delayed status
int buttonstate; // variable hold button state
int lightmode = 0; // mode light in?
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void setup() {
//lcd setup
// set lcd's number of rows , columns:
lcd.begin(16, 2);
// print message lcd.
lcd.print("**midi nights**");
delay (1000);
lcd.setcursor(0, 4);
lcd.print("led menu options");
delay (1000);
lcd.clear();
// resets cursor position
lcd.setcursor(0, 4);
lcd.print(" use right/left buttons select led ");
delay (20);
// scroll 150 positions (string length) left
// move offscreen left:
for (int positioncounter = 0; positioncounter < 27; positioncounter++) {
// scroll 1 position left:
lcd.scrolldisplayleft();
// wait bit:
delay(50);
}
lcd.clear(); //clear screen , reset cursor
lcd.setcursor(1, 9);
lcd.print("select led < >"); //select desired led
delay (4000); // delays on screen goes led choices
//button setup
pinmode(switchpin1, input); // set switch pin input menu right
pinmode(switchpin2, input); // set switch pin input menu left
pinmode(switchpin3, input); // set switch pin input menu up
pinmode(switchpin4, input); // set switch pin input menu down
pinmode(switchpin5, input); // set switch pin input menu store
pinmode(led1pin, output); // leds outputs become leds 1-33 (11 led selections 3 colors each)
pinmode(led2pin, output); // right each button press lights same light
pinmode(led3pin, output); // ultimate goal charlieplex decoder , latches
pinmode(led4pin, output);
pinmode(led5pin, output);
serial.begin(9600); // set serial communication @ 9600bps
buttonstate = digitalread(switchpin1); // read initial state
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void loop() {
val = digitalread(switchpin1); // read input value , store in val
delay(10); // 10 milliseconds amount of time
val2 = digitalread(switchpin1); // read input again check bounces
if (val == val2) { // make sure got 2 consistant readings!
if (val != buttonstate) { // button state has changed!
if (val == low) { // check if button pressed
if (lightmode == 0) { // if off
lightmode = 1; // turn light on!
} else {
if (lightmode == 1) { //
lightmode = 2; //
} else {
if (lightmode == 2) { //
lightmode = 3; //
} else {
if (lightmode == 3) { //
lightmode = 4; //
} else {
if (lightmode == 4) { //
lightmode = 5; //
} else {
if (lightmode == 5) { //
lightmode = 0; //
}
}
}
}
}
}
}
}
buttonstate = val; // save new state in our variable
}
// whatever lightmode indicates
if (lightmode == 0) { // led on
digitalwrite(led1pin, high);
lcd.clear();
lcd.print("led 1");
delay (100);
}
if (lightmode == 1) { // led on
digitalwrite(led1pin, high); //turns on led
lcd.clear(); // clears screen
lcd.print("led 2"); // name of led
delay (100); // delay keep lcd flashing while looping, not after
}
if (lightmode == 2) { // led on
digitalwrite(led1pin, high);
lcd.clear();
lcd.print("led 3");
delay (100);
}
if (lightmode == 3) { // led on
digitalwrite(led1pin, high);
lcd.clear();
lcd.print("led 4");
delay (100);
}
if (lightmode == 4) { // led on
digitalwrite(led1pin, high);
lcd.clear();
lcd.print("led 5");
delay (100);
}
if (lightmode == 5) { // led on
digitalwrite(led1pin, high);
lcd.clear();
lcd.print("led 6");
delay (100);
}
}
code: [select]
if (lightmode == 0) { // if off
lightmode = 1; // turn light on!
} else {
if (lightmode == 1) { //
lightmode = 2; //
} else {
if (lightmode == 2) { //
lightmode = 3; //
} else {
if (lightmode == 3) { //
lightmode = 4; //
} else {
if (lightmode == 4) { //
lightmode = 5; //
} else {
if (lightmode == 5) { //
lightmode = 0; //
}
can introduce mr switch statement?
http://arduino.cc/en/reference/switchcase
or ms modulo?
http://arduino.cc/en/reference/modulo
one other minor thing:
code: [select]
// constants won't change. they're used here to
// set pin numbers:
const int ledpin = 13; // number of led pin
int switchpin1 =12; // switch1 connected pin 12
int switchpin2 =11; // switch2 connected pin 11
int switchpin3 =10; // switch3 connected pin 10
int switchpin4 =9; // switch4 connected pin 9
int switchpin5 =8; // switch5 connected pin 8
int led1pin = 13;
int led2pin = 8;
int led3pin = 9;
int led4pin = 10;
int led5pin = 12;
as per comment, mean plan on dynamically moving these led , switch pins?
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > LCD menu options (best route)
arduino
Comments
Post a Comment