Trying To Get Led To Blink 10 Times, Don't Know What's Wrong

trying to get led to blink 10 times, don't know what's wrong Other Hardware LEDs and Multiplexing January 22, 2018, 10:08pm 1

const int LED = 13; int count = 0;

void setup() { pinMode (LED, OUTPUT);

} void blinkLED(int timeOn, int timeOff, int numBlinks) { for (count= 0; count <= numBlinks-1; count++) { digitalWrite(LED, HIGH); delay(timeOn); digitalWrite(LED, LOW); delay(timeOff); } }

void loop() { blinkLED(1000,1000,10); }

January 22, 2018, 10:25pm 2

Nothing wrong with that code it works. Except of course it is not posted correctly, read How to use this forum

What is it doing that you don't want it to do?

Are you expecting it to stop after 10 blinks? No the loop function will repeat the blinks over and over.

January 22, 2018, 10:26pm 3

It doesn't blink 10 times, it just keeps going and doesn't stop

January 22, 2018, 10:27pm 4

Yes it will. The loop function does just that it loops.

January 22, 2018, 10:31pm 5

Move this line

blinkLED(1000,1000,10);

from loop() into setup()

January 22, 2018, 10:33pm 6

Or add

while(1) { }

To the end of the loop function.

Topic Replies Views Activity
10 Blinks Programming 3 1167 May 5, 2021
TinkerCad - LED blink LEDs and Multiplexing 1 1188 May 6, 2021
How to repeat a loop only a certain number of times? Programming 16 124317 May 5, 2021
How do i blink the LED's for 100 times and then turn them off with the micros()? Programming 6 388 November 9, 2022
Problem with 10 leds blinking project. Programming 6 1301 May 6, 2021
Unfortunately, your browser is unsupported. Please switch to a supported browser to view rich content, log in and reply.

Tag » Arduino Blink Led 10 Times