I have been developing this version of my disco light controller, and learing a lot about electronics an pbp along the way. However I've hit a small problems with getting LEDs to chase correctly to the beat of the music.
I have managed to filter the base beat using an NE555 and this provides a nice +5 logic pulse in time with the beat. However I'm finding that using the code below the lights cycle through the sequence too quick. What I'm after is for the LEDs to step through the sequence one at a time, where as at the moment it loops round, still finds the beat is present and jumps another setp, loops round again and does the same, until the beat isn't present. Whilst I could put in a larger pause, this could then cause problems of the code missing a beat on tracks with a faster beat. Is there anyway to detect just the initial change from low to high of the pin, thus ignoring the remainder of the time the pin is high, and then reset itself when the pin goes low again ? Or would this be too complicated ??
Here's the code for the music section
Code:
music:
read patt[swcount],steps ;read the first value of the selected patter and place it in the variable steps
READ PATT[SWCOUNT]+ C,PORTB ;reads the step value for selected pattern and send it to PORTB
If switch2=1 then C=C+1
pause 10
If C=steps then C=1
goto music:
Bookmarks