My display is stuck on the same screen and not looping! Could someone help me with where am i going wrong? I use U8GLIB... Please correct the code below
#include <Keypad.h>
#include "U8glib.h"
U8GLIB_ST7920_128X64_4X u8g(13, 12, 11);
const byte numRows= 4;
const byte numCols= 4;
char keymap[numRows][numCols]= {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[numRows] = {3,4,5,6};
byte colPins[numCols] = {7,8,9,10};
Keypad mykeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
char Password=1*2*3;
void setup()
{
u8g.firstPage ();
do{
welcome ();
} while( u8g.nextPage () );
delay(3000);
u8g.setColorIndex (1);
}
void welcome(void)
{
u8g.setFont(u8g_font_fub17);
u8g.setPrintPos(16, 25);
u8g.setColorIndex(1);
u8g.drawBox(0,0,128,64);
u8g.setColorIndex(0);
u8g.print("Welcome!");
}
void authentication()
{
char uauth;
u8g.setFont(u8g_font_helvR08);
u8g.setPrintPos(16, 25);
u8g.print("Please enter device");
u8g.setPrintPos(20, 46);
u8g.print("PASSWORD");
uauth = mykeypad.waitForKey();
if (uauth=Password)
{
u8g.firstPage();
do{
MainMenu();
} while( u8g.nextPage() );
}
u8g.setFont(u8g_font_fub17);
u8g.setPrintPos(16, 25);
u8g.print("Invalid Password");
}
void MainMenu(void)
{
int MainOption;
u8g.setFont(u8g_font_helvR08);
u8g.setPrintPos(2, 25);
u8g.print("Choose the options below");
u8g.setFont(u8g_font_fub17);
u8g.setPrintPos(16, 25);
u8g.print(" 1. First Option");
u8g.setPrintPos(16, 25);
u8g.print(" 2. Second Option");
u8g.setPrintPos(16, 25);
u8g.print(" 3. Third Option");
MainOption = mykeypad.getKey();
if(MainOption=1)
{
u8g.setFont(u8g_font_unifont);
u8g.setPrintPos(64, 32);
u8g.print(MainOption);
}
else if(MainOption=2)
{
u8g.setFont(u8g_font_unifont);
u8g.setPrintPos(64, 32);
u8g.print(MainOption);
}
else if(MainOption=3)
{
u8g.setFont(u8g_font_unifont);
u8g.setPrintPos(64, 32);
u8g.print(MainOption);
}
else
{
u8g.setFont(u8g_font_unifont);
u8g.setPrintPos(20, 26);
u8g.print("Invalid choice...");
u8g.setPrintPos(26, 48);
u8g.print("Try again!");
}
}
void loop(void)
{
u8g.firstPage ();
do{
authentication ();
} while( u8g.nextPage () );
}
//delay(500);
i have attached the photos!