Go Down

Topic: 4 led strobe/chaser multi patterns and speed help (Read 1 time) previous topic - next topic

koteman

for my second program im trying is to make 4 sets of leds capable of doing multiple store and chase patterns with the push of a button and change the speed with a pot. i also want to find the easiest way to add new patterns in the code so are there any generators for the pattern portion of the code or a what i can write out codes with out a bunch of delays. i have done lots of looking in to this but can really only find code for the night rider effect which i don't really want cause its only 4 sets. so if you all have any direction on where to start that would be appreciated.

Thank you,
     Koteman

johnwasser

Well, the speed control is easy.  The pot on an analog input will give values from 0 to 1023.  You can use the 'map' function to change the top and bottom of the range:
Code: [Select]
int speedDelay = map(analogRead(potPin,0,1023,10,300)); // speed delays from 10 to 300 milliseconds
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

rickso234

Write a few simple functions to turn on and off the sets and pass a delay value to the function to set the on/off time, then call the function in a loop. Start out simple and build on what you have. You should be able to make some interesting patterns.

Go Up