Hi,
Not quite sure if someone will be able to help me but..........
I am currently trying to build a menu layout for a 20x4 LCD. I originally had the LCD working with the keypad to have a title screen and password login with password right and wrong screens.
I am using an Arduino Uno which is plugged into an 20x04 LCD (1602 model shown in fitzrig) via I2C Connection. The 4x4 Matrix keypad is plugged into the uno using pins 6-13.
After I have mastered the menu layout on the LCD I will add in a clock module for time and date and LED's which will hopefully be controlled using a transistor to reduce the amount of pins used by the Arduino.
After adding the bits of menu coding I have been getting continuous errors. Most I have been able to solve up until this point changing H files etc, but now I am at a bit of a loss as to what to change next as I am a beginner to arduino and coding. the problem is occurring at line 249. The error message I am receiving is:
Menu_Control_Un o.ino:249:2: error: expected unqualified-id before 'if'
Error compiling.
The menu program seems to compile on its own without the keypad and LCD code, as soon as I put them all together I have had to work through errors. Because the menu isn't working with my LCD I can not tell what exactly the code has done so I can alter it to suit my own needs.
any help out be greatly appreciated
The Arduino code is as follows: line 249 is the first line of the menu loop starting with the word "if"
if (Serial.availab le()){
switch (Serial.read()) {
case 'w':
if (menu.isCurrent SubMenu()){
subMenu.down(); //set index closer to 0
}
break;
case 's':
if (menu.isCurrent SubMenu()){
subMenu.up(); //set index closer to maximum
}
break;
case 'a':
menu.down();
break;
case 'd':
menu.up();
break;
case ' ':
menu.use();
break;
case '0':
menu.select(0);
break;
case '1':
menu.select(1);
break;
case '2':
menu.select(2);
break;
}
}
}
void menuChanged(Ite mChangeEvent event){
Serial.println( "menuChange d");
if( event == &menuItem1 ){
Serial.println( "\tmenuItem 1 selected"); //user feedback
}else if( event == &menuItemWithSu bmenu ){
Serial.println( "\tmenuItemWith Submenu selected"); //user feedback
}else if( event == &subMenuItem 1 ){
Serial.println( "\tsubMenuI tem1 selected"); //user feedback
}else if( event == &subMenuItem 2 ){
Serial.println( "\tsubMenuI tem2 selected"); //user feedback
}else if( event == &subMenuItem 3 ){
Serial.println( "\tsubMenuI tem3 selected"); //user feedback
}else if( event == &menuItem3 ){
Serial.println( "\tmenuItem 3 selected"); //user feedback
}
}
void menuUsed(ItemUs eEvent event){
Serial.println( "menuUsed") ;
if( event == &menuItem1 ){
Serial.println( "\tmenuItem 1 used"); //user feedback
}else if( event == &subMenuItem 1 ){
Serial.println( "\tsubMenuI tem1 used"); //user feedback
}else if( event == &subMenuItem 2 ){
Serial.println( "\tsubMenuI tem2 used"); //user feedback
}else if( event == &subMenuItem 3 ){
Serial.println( "\tsubMenuI tem3 used"); //user feedback
}else if( event == &menuItem3 ){
Serial.println( "\tmenuItem 3 used"); //user feedback
}
}
Not quite sure if someone will be able to help me but..........
I am currently trying to build a menu layout for a 20x4 LCD. I originally had the LCD working with the keypad to have a title screen and password login with password right and wrong screens.
I am using an Arduino Uno which is plugged into an 20x04 LCD (1602 model shown in fitzrig) via I2C Connection. The 4x4 Matrix keypad is plugged into the uno using pins 6-13.
After I have mastered the menu layout on the LCD I will add in a clock module for time and date and LED's which will hopefully be controlled using a transistor to reduce the amount of pins used by the Arduino.
After adding the bits of menu coding I have been getting continuous errors. Most I have been able to solve up until this point changing H files etc, but now I am at a bit of a loss as to what to change next as I am a beginner to arduino and coding. the problem is occurring at line 249. The error message I am receiving is:
Menu_Control_Un o.ino:249:2: error: expected unqualified-id before 'if'
Error compiling.
The menu program seems to compile on its own without the keypad and LCD code, as soon as I put them all together I have had to work through errors. Because the menu isn't working with my LCD I can not tell what exactly the code has done so I can alter it to suit my own needs.
any help out be greatly appreciated
The Arduino code is as follows: line 249 is the first line of the menu loop starting with the word "if"
if (Serial.availab le()){
switch (Serial.read()) {
case 'w':
if (menu.isCurrent SubMenu()){
subMenu.down(); //set index closer to 0
}
break;
case 's':
if (menu.isCurrent SubMenu()){
subMenu.up(); //set index closer to maximum
}
break;
case 'a':
menu.down();
break;
case 'd':
menu.up();
break;
case ' ':
menu.use();
break;
case '0':
menu.select(0);
break;
case '1':
menu.select(1);
break;
case '2':
menu.select(2);
break;
}
}
}
void menuChanged(Ite mChangeEvent event){
Serial.println( "menuChange d");
if( event == &menuItem1 ){
Serial.println( "\tmenuItem 1 selected"); //user feedback
}else if( event == &menuItemWithSu bmenu ){
Serial.println( "\tmenuItemWith Submenu selected"); //user feedback
}else if( event == &subMenuItem 1 ){
Serial.println( "\tsubMenuI tem1 selected"); //user feedback
}else if( event == &subMenuItem 2 ){
Serial.println( "\tsubMenuI tem2 selected"); //user feedback
}else if( event == &subMenuItem 3 ){
Serial.println( "\tsubMenuI tem3 selected"); //user feedback
}else if( event == &menuItem3 ){
Serial.println( "\tmenuItem 3 selected"); //user feedback
}
}
void menuUsed(ItemUs eEvent event){
Serial.println( "menuUsed") ;
if( event == &menuItem1 ){
Serial.println( "\tmenuItem 1 used"); //user feedback
}else if( event == &subMenuItem 1 ){
Serial.println( "\tsubMenuI tem1 used"); //user feedback
}else if( event == &subMenuItem 2 ){
Serial.println( "\tsubMenuI tem2 used"); //user feedback
}else if( event == &subMenuItem 3 ){
Serial.println( "\tsubMenuI tem3 used"); //user feedback
}else if( event == &menuItem3 ){
Serial.println( "\tmenuItem 3 used"); //user feedback
}
}
Comment