I have written a code for following task
when I pressed a push button(pin 2) i need to blink LED once(pin 13) for 1 S. but still push button should be pressed.
Here is my code. it is not working. please help me to do my project.
int ledPin = 13;
volatile int buttonState = LOW;
void setup() {
pinMode(ledPin, OUTPUT);
//Attach the Interrupt
attachInterrupt(0, InterruptMenu, RISING); // INTERRUPT PIN 2 for UNO
}
void loop(){
if (buttonState == HIGH)
{
digitalWrite(ledPin, buttonState);
delay(1000);
buttonState = LOW;
}
}
udrkapuduwa:
Here is my code. it is not working. please help me to do my project.
OK, first and most critical thing to do (especial if you are new to this) is to forget any code to do with interrupts, and start by figuring out how you need to approach the problem - make a list of steps and work through them.
When you have a rough code to do it (read through a lot of other similar discussions), post it using the "code" tags generated by the [ # ] button above the submission window.