Go Down

Topic: Running more than one event listeners (Read 1 time) previous topic - next topic


I've been snoozing the past year when I should have been learning more, thus newbie program. I've seen it before but can't remember a single thing about how to accomplish it. Here I have a LED blink on else if no button is pressed. I'm puzzled on how to make it do this without the delay to read the instruction to write to LED when the push button I have is triggered.

If I failed to explain, I wish to have the LED blink but respond to the push button listener that tells the program to turn the LED on. My program however, will only listen at one moment in the instructions as it runs the loop. How can I solve this?

Code: [Select]
const int ledPin = 13;
const int buttonPin = 53;
int buttonState = 0;

void setup(){
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);

void loop(){  //
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH)  {
  digitalWrite(ledPin, HIGH);
else  {
   digitalWrite(ledPin, HIGH);
   digitalWrite(ledPin, LOW);


Open the Arduino IDE, go to File => Examples => Digital => Blink without delay.

Go Up