Jump to content

How to blink randomly?

Recommended Posts

Yo, there Im using a tm4c1294nctd, Im wondering how to modify the existing blink example to make the internal led (D2/PF4) blinks randomly instead of a fixed time.

Im trying to modify the

digitalWrite(LED, HIGH);

digitalWrite(LED, HIGH);

with someting like

digitalWrite(LED[j], HIGH);

      j = (j+1) % 5;

But I realized this is gonna run over a given number of leds instead of time.

I humbly request ideas.

Thanks in advance!!!

Link to post
Share on other sites

Rei Vilo  hit the main point


I will ask WHICH blink example you are referring to. There are a number of them.


Background: the basic structure is that you turn on the LED, have a delay, turn off the LED, and another delay. What you did include your message does not show the delay... it is what turn on hte LED. There is a delay somewhere, and that is where you want the random value.



You may want to restrict the random value to a certain range to keep the random blinking reasonable in appearance.

Link to post
Share on other sites
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...