You are still overcoding....
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <windows.h>
int main (void)
{
int BTNpress = 0; //To mimic press of button, a 1 = button has been pressed.
int LEDStat = 0; //LED is initialy off(0)
while (TRUE) //loop to scan the button state
{
puts( "Press Enter to press the button");
getchar(); <--- it's going to sit here until you push the button, it's not going anywhere
if (BTNpress && !LEDStat) <--- bold faced text is unnecessary
{ //printf("The button has been pressed\n");
printf("LED is ON\n");
LEDStat = 1; }
else if (BTNpress && LEDStat) <---- since there are only two posible states this is unnecessary {
{ //printf("The button has been pressed\n");
printf("LED is OFF\n");
LEDStat = 0; }
}
system("PAUSE");
return 0;
}
Leaving you with.....
Code:
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <windows.h>
int main (void)
{ int LEDStat = 0; //LED is initialy off(0)
while (TRUE) //loop to scan the button state
{
puts( "Press Enter to press the button");
getchar();
if (!LEDStat)
{ printf("LED is ON\n");
LEDStat = 1; }
else
{ printf("LED is OFF\n");
LEDStat = 0; }
}
system("PAUSE");
return 0;