Hello, everyone!
I am currently working on a fairly simple project of making 7 (channel) LED chaser. Nothing special. I am just planning to connect 7 or more LEDs to 7 outputs of PICAXE-20M2 (from B.1 to B.7 respectively) via ULN2003 chip to handle more power. I have written some pretty basic code, part of which I am posting here. After running it using simulator function of PICAXE Editor software everything seems just fine.
My question is: How can I vary the speed at which the LEDs turn on and off by using the built-in "pause" command? Is there a way to change the values of all "pause" commands in the block of code at once via some line of code or using some external signal inputs (like switches, pots etc.)? I know I could just retype all values by hand and reload the program into the IC again, but this is cumbersome and I don't want to use the computer again each time I need to change the switching speed of the LEDs.
Thanks in advance for help!
symbol LED1 = B.1 ; rename outputB1 LED1
symbol LED2 = B.2 ; rename outputB2 LED2
symbol LED3 = B.3 ; rename outputB3 LED3
symbol LED4 = B.4 ; rename outputB4 LED4
symbol LED5 = B.5 ; rename outputB5 LED5
symbol LED6 = B.6 ; rename outputB6 LED6
symbol LED7 = B.7 ; rename outputB7 LED7
symbol counter = b0 ; define a counter using variable b0
main:
gosub pattern
goto main
pattern: ; all LEDs light up one after another
for counter = 1 to 3 ; start a for...next loop
high LED1 ; turn on LEDs
pause 1000
high LED2
pause 1000
high LED3
pause 1000
high LED4
pause 1000
high LED5
pause 1000
high LED6
pause 1000
high LED7
pause 1000
low LED1 ; turn off LEDs
pause 1000
low LED2
pause 1000
low LED3
pause 1000
low LED4
pause 1000
low LED5
pause 1000
low LED6
pause 1000
low LED7
pause 1000
next counter ; end of for...next loop
end
I am currently working on a fairly simple project of making 7 (channel) LED chaser. Nothing special. I am just planning to connect 7 or more LEDs to 7 outputs of PICAXE-20M2 (from B.1 to B.7 respectively) via ULN2003 chip to handle more power. I have written some pretty basic code, part of which I am posting here. After running it using simulator function of PICAXE Editor software everything seems just fine.
My question is: How can I vary the speed at which the LEDs turn on and off by using the built-in "pause" command? Is there a way to change the values of all "pause" commands in the block of code at once via some line of code or using some external signal inputs (like switches, pots etc.)? I know I could just retype all values by hand and reload the program into the IC again, but this is cumbersome and I don't want to use the computer again each time I need to change the switching speed of the LEDs.
Thanks in advance for help!
symbol LED1 = B.1 ; rename outputB1 LED1
symbol LED2 = B.2 ; rename outputB2 LED2
symbol LED3 = B.3 ; rename outputB3 LED3
symbol LED4 = B.4 ; rename outputB4 LED4
symbol LED5 = B.5 ; rename outputB5 LED5
symbol LED6 = B.6 ; rename outputB6 LED6
symbol LED7 = B.7 ; rename outputB7 LED7
symbol counter = b0 ; define a counter using variable b0
main:
gosub pattern
goto main
pattern: ; all LEDs light up one after another
for counter = 1 to 3 ; start a for...next loop
high LED1 ; turn on LEDs
pause 1000
high LED2
pause 1000
high LED3
pause 1000
high LED4
pause 1000
high LED5
pause 1000
high LED6
pause 1000
high LED7
pause 1000
low LED1 ; turn off LEDs
pause 1000
low LED2
pause 1000
low LED3
pause 1000
low LED4
pause 1000
low LED5
pause 1000
low LED6
pause 1000
low LED7
pause 1000
next counter ; end of for...next loop
end