Arduino LED race


I had an idea in mind to make a bunch of LED's race against eachother with pressing a button. And on each turn there is a random number generated that makes the LED's ''walk''. But i've no idea how to count up LED's with generating a random number.
Hope you can help me with my problem

Your sincerely,

Why don't you start by posting all required info about your project as mentioned in the sticky?

Isn't that what I did? And What's the reason behind giving a mean comment towards me when i'm clearly just asking for help. Fair enough if you're not willing to help just ignore the topic then. And go on there's no reason to leave such a comment like this. I get that you get annoyed by people that are really new to this kind of stuff but patience, is clearly the thing you need with people that are willing to learn something and just asks for help.

Well, there's no clear question. There's no info on what you tried. There's no info on what hardware you use. Or info that gives a clue on what "count up LED's with generating a random number" could possibly mean.

Based on the info given there's no chance for useful help. Do your homework and be clear in what you want and where exactly you're stuck and help will be on the way really quickly.


The clear question is that I myself don't know how to use the value's I get from my random function. So that value I get kinda like a dice 1-6, I want to use that value to count up led's from 0-10. If I can get that knowledge I can finish my project.

use the random function.

Yea I already know that!
But I don't know how I can use the random function to count up led's I know I have to use the random function for it I just don't know how I can make these value's respond to the led's that I want to count up.

Well, for lack of any other information about your project and what you're actually trying to do, neither do I.

I litterly have 2 rows of 10 LED’s connected to an arduino mega. Further there are 2 pushbuttons attatched with it for each row 1. If i press one of the buttons i want a random number to be generated. So that I can make those 2 rows of led’s race against eachother. Is that clear enough?

I'm struggling with the same problem!

Finally someone that understands me :smiley:

Classmates struggling with the same "race"? Or struggling with understanding what is going on here?

And no, not clear enough. Remember I don't have a crystal ball.

So you get a random number 1-10. Fine. Now what does that do with the TWO rows of LEDs? How do they "race"? What determines the "winner"? What does that number do to this "race"?

So First of all not a random number from 1-10 i have two rows of 10 leds that litterly race against eachother with the press of a button. And that button generates a random number from 1-6. That can determine who wins. So in the end it's just a game of luck.

  1. Create 2 variables, starting at 0, corresponding to each row of LEDs.
  2. Generate a random value and scale that to a value between 0 and 1 (so that you don't make huge jumps in numbers of
    LEDs advanced).
  3. Add that number to the running total of the 1st variable.
  4. Repeat 2 & 3 for LED variable 2.
  5. Wait a period of time to observe the results.
  6. Repeat 2, 3, 4, and 5 until one row lights its last LED.

Thanks for your response! I really apreciate it! I can finally continue with my project!

Classmates struggling with the same "race"?

Same IP address, so I'm saying yes.