Hi all
Am trying to write some basic code to handle buttons, there are 41 in all, I’m starting with button 7. What I want it to do is to light an LED on a DOut when pushed first and if pushed again, put the LED out.
Am using a long case statement, here is the code for button 7:
case 7:
if ( st40 == 0){
st40=1;
MIOS32_DOUT_PinSet(40, 1);
MIOS32_LCD_CursorSet(0, 2); // X, Y
MIOS32_LCD_PrintFormattedString(“Status %d”,st40);
MIOS32_LCD_CursorSet(0, 3); // X, Y
MIOS32_LCD_PrintFormattedString("Button 7 pressed on ");
}
else if (st40 == 1){
st40=0;
MIOS32_DOUT_PinSet(40,0);
MIOS32_LCD_CursorSet(0, 2); // X, Y
MIOS32_LCD_PrintFormattedString(“Status %d”,st40);
MIOS32_LCD_CursorSet(0, 3); // X, Y
MIOS32_LCD_PrintFormattedString(“Button 7 pressed off”);
}
break;
What happens is that the LED is lit only whilst the button is pressed, when released it goes off. Although sometimes it stays on forever…
Can’t see whats wrong, so anyone got any ideas?
Thanks
S