Been a while since I have been on here but have a need for a circuit for my 11 year old son's r/c car.
Need to flash headlights in different patterns by pressing a push button switch on pin 3, then return to the first after the 3rd sequence is reached. Been looking for examples for state machines, loops and push button presses and stumbled upon this from lbenson in 2010:-
I was looking at the code and understanding how it works and seeing how I can make changes to implement my needs. I added some changes to the case states taking into account I am using an original 08M
The above outputs are just and example. Problem I have is the selected case only runs once. How can I tie it into the loop so the selected mode runs continually until interrupted by a button press. Been studying the manuals and other examples, making change, tried gosubs but scratching my head.
many thanks in advance and to lbenson for his advice and code snippet.
Ash
Need to flash headlights in different patterns by pressing a push button switch on pin 3, then return to the first after the 3rd sequence is reached. Been looking for examples for state machines, loops and push button presses and stumbled upon this from lbenson in 2010:-
Code:
symbol mode=b13
do
if pin3 = 1 then
do loop until pin3 = 0
mode = mode + 1
if mode > 3 then
mode = 1
endif
low B.1
low B.2
low B.3
select mode
case 1: HIGH B.1
case 2: HIGH B.2
case 3: HIGH B.3
end select
endif
loop
Code:
symbol mode=b13
do
if pin3 = 1 then
do loop until pin3 = 0
mode = mode + 1
if mode > 3 then
mode = 1
endif
select mode
case 1
high 0
pause 500
low 0
pause 500
case 2
high 1
pause 500
low 1
pause 500
case 3
high 2
pause 500
low 2
pause 500
end select
endif
loop
many thanks in advance and to lbenson for his advice and code snippet.
Ash