Quantcast
Channel: fritzing forum - Latest posts
Viewing all articles
Browse latest Browse all 28182

Help needed with a random color RGB LED program

$
0
0

I gathered that was what you were trying to do :slight_smile: however the LEDs don't do random. They are either on or off (as is the port) so to create random light you would need to get a random value, decide on some criteria if it is 0 or 1 (aka LOW and HIGH although 0 and 1 will work as well) to write to the port. So in your loop you should call random (to get a new random value) decide if it is closer to 0 or 1 and then write the 0 or 1 to one of the led colors. Now do the same thing twice more but instead write the 0 or 1 to the next color of led. Once you have set all three to a random value then sleep for a while and repeat. To get more range than this you would need to arrange to use the pwm ports on the Arduino to set random intensitys but that is a fair bit more complex that this.


Viewing all articles
Browse latest Browse all 28182

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>