I would like to make a simple embedded program that will Display what is happening on and LCD screen. When Switch One is pressed, it displays "Switch One". When Switch 2 is pressed it displays Switch 2. When both switches are pressed is displays "Both Switch". For the life of my I cannot get it to display "Both Switches" on the LCD when both switches are pressed. I have Switch 1 attached to RB0 and Switch 2 attached to RB1. Both switches display properly until I press both switches and what usually displays is the first one pressed. Please help!! Here is my code:
C:
if (switch1 == 0)
{
__delay_ms(10);
while (switch1 == 0)
{
for (a = b; a < 1; a++)
{
lcd_clear();
}
lcd_goto(0);
lcd_puts("Switch 1");
b = 1;
}
}
if (switch2 == 0)
{
__delay_ms(10);
while (switch2 == 0)
{
for (a = b; a < 1; a++)
{
lcd_clear();
}
lcd_goto(0);
lcd_puts("Switch 2");
b = 1;
}
}
if (PORTB == 0xFC)
{
__delay_ms(10);
while (PORTB == 0xFC)
{
for (a = b; a < 1; a++)
{
lcd_clear();
}
lcd_goto(0);
lcd_puts("Both Switches");
b = 1;
}
}
Last edited: