Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Embedded Programming Suggestion Needed
I am new to embedded programming. I am intended to prompt for input to control two LEDs. I there a better way of doing this? This is what I got; this code is tested working but I know there got to be a normal way that embedded programmer accustom to be using for example using mask etc? Would anyone care to give me some better suggestion?
int main() { int i; while (1) { pc.printf ("\n\r Please Enter hex number: "); pc.scanf ("%x", &i ); if ( i == 0x03) { pc.printf ("\n Three "); bit0 = 1; bit1 = 1; } else if (i == 0x02){ pc.printf ("\n Two "); bit0 = 0; bit1 = 1; } else if (i == 0x01) { pc.printf ("\n One "); bit0 = 1; bit1 = 0; } else { pc.printf ("\n Zero "); bit0 = 0; bit1 = 0; } wait(1); } }