system
June 22, 2013, 2:58pm
1
error may be the internal mechanism..i dont know but its not working.any ideas?
hardware connections={switch to pin 8,pull down to ground taken care of;.
7 is pulled down,and 12 is connected to pin 7.
int state=0;
void setup()
{
pinMode(8,INPUT);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(7,INPUT);
attachInterrupt(7,isr,RISING);
}
void isr()
{
digitalWrite(13,!state);
}
void loop()
{
if(8==HIGH);
{
digitalWrite(12,1);
delay(500);
digitalWrite(12,0);
}
}
system
June 22, 2013, 3:01pm
2
if(8==HIGH);
{
Since HIGH is defined as 1, this test will never evaluate to true.
Even if it did, the body of the if statement is the semicolon, which is a no-op.
So, what was the point of this code?
What was your question?
system
June 22, 2013, 3:08pm
3
pratiik4562:
updated
hardware connections={switch to pin 8,pull down to ground taken care of;.
7 is pulled down,and 12 is connected to pin 7.
int state=0;
void setup()
{
pinMode(8,INPUT);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
attachInterrupt(0,isr,RISING);
}
void isr()
{state=!state;
digitalWrite(13,!state);
}
void loop()
{
if(digitalRead(8)==HIGH);
{
digitalWrite(12,1);
delay(500);
digitalWrite(12,0);
}
}
system
June 22, 2013, 3:15pm
4
if(digitalRead(8)==HIGH);
The semicolon STILL doesn't belong there.
Your LED won't blink, by the way, since there is no OFF time.
system
June 26, 2013, 3:05pm
5
i debugged all programing errors man tell me the logical problem lol...
system
June 26, 2013, 3:05pm
6
basically i want to trigger a interrupt with a button but i dont have a inverse schmitt trigger.so any way i can do that?
system
June 26, 2013, 4:17pm
7
basically i want to trigger a interrupt with a button
OK. Connect the button (or, even better, a switch) to one of the external interrupt pins. Add an interrupt handler, using attachInterrupt().
You can debounce the switch in software (simply ignore any change that happens too soon after the last one. Use millis() to determine when stuff happens).
You'll have a really hard time debouncing the switch in hardware without any hardware.