basic switch program inarduino

Status
Not open for further replies.

Bhuvanesh Nick

Member level 1
Joined
Aug 22, 2013
Messages
33
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Visit site
Activity points
201
int x=0;
void setup()
{
Serial.begin(14400);
Serial.print("starting");
Serial.println("Program");
pinMode(13,OUTPUT);
pinMode(7,INPUT);
digitalWrite(7,HIGH);//internal pull up
}
void loop()
{
if(digitalRead(7)==0)
{
x=!x;

digitalWrite(13,x);

while(digitalRead(7)==0);
delay(50);//debounce of the spring action of switch
Serial.print(x);

}}



once i press the button its blowing.but next time time when i press its blowing off how is that
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…