Blazemaguire
Senior Member
Hi guys,
I am still in my infancy of writing in BASIC, - I learnt PICAXE as a necessity for my teaching, but have so far been using PIC Logicator and flow charts.... so apologies if my code is hard to follow, or not in a traditional format, but i'm still learning!
Anyhow, all morning i've been working on this piece of code and have managed to get all the LED's connected to the eight outputs of a 20M brightening and dimming in a repeating cycle using the code below.
The effect looks quite cool, but what I want to know is, is there a way of making the LED's go even dimmer, or even brighter without them visually 'flickering'. In my code you can see the symbol 'Max_Limit'. - If I set this above 16 I get better peak brightness and darkness, but then the LED's 'flicker' presumably because my eye is catching up with the pulsing rate.
Is there anyway around this? (I will experiment with PWM later on) or have I just reached the limits of LED dimming / brightening abilities?
Anyhow, feel free to tear my code apart and suggest any improvements. - It make sense to my head.... I guess the test is if others can interpret it!
symbol max_limit = 16
symbol min_limit = 1
symbol cycle_time= 2
main:
b2=min_limit
b3 = max_limit
b5=0
goto flash_dim
flash_dim:
inc b5
if b2>= max_limit then goto recal_2
let pins = %11111111
pause b3
let pins = %00000000
pause b2
if b5 = cycle_time then goto recal
goto flash_dim
recal:
inc b2
dec b3
b5=0
goto flash_dim
recal_2:
inc b3
dec b2
b5=0
goto flash_bright
flash_bright:
inc b5
if b3>=max_Limit then goto recal
let pins = %11111111
pause b3
let pins = %00000000
pause b2
if b5 = cycle_time then goto recal_2
goto flash_bright
thanks Rob
I am still in my infancy of writing in BASIC, - I learnt PICAXE as a necessity for my teaching, but have so far been using PIC Logicator and flow charts.... so apologies if my code is hard to follow, or not in a traditional format, but i'm still learning!
Anyhow, all morning i've been working on this piece of code and have managed to get all the LED's connected to the eight outputs of a 20M brightening and dimming in a repeating cycle using the code below.
The effect looks quite cool, but what I want to know is, is there a way of making the LED's go even dimmer, or even brighter without them visually 'flickering'. In my code you can see the symbol 'Max_Limit'. - If I set this above 16 I get better peak brightness and darkness, but then the LED's 'flicker' presumably because my eye is catching up with the pulsing rate.
Is there anyway around this? (I will experiment with PWM later on) or have I just reached the limits of LED dimming / brightening abilities?
Anyhow, feel free to tear my code apart and suggest any improvements. - It make sense to my head.... I guess the test is if others can interpret it!
symbol max_limit = 16
symbol min_limit = 1
symbol cycle_time= 2
main:
b2=min_limit
b3 = max_limit
b5=0
goto flash_dim
flash_dim:
inc b5
if b2>= max_limit then goto recal_2
let pins = %11111111
pause b3
let pins = %00000000
pause b2
if b5 = cycle_time then goto recal
goto flash_dim
recal:
inc b2
dec b3
b5=0
goto flash_dim
recal_2:
inc b3
dec b2
b5=0
goto flash_bright
flash_bright:
inc b5
if b3>=max_Limit then goto recal
let pins = %11111111
pause b3
let pins = %00000000
pause b2
if b5 = cycle_time then goto recal_2
goto flash_bright
thanks Rob