trevorboultwood
Member
Hello there, I bought a bargraph LED yesterday from my beloved store Maplin I have been experimenting with them making really cool patterns and I thought I would then create a binary count up. My first attempt was just to do the first 5 numbers (1,2,4,8,16) This went fine doing a continueous command of highs and lows. I then decided to carry it on by adding many sub routines to make it the full 10 lines of the LEDs. Again this went superb. I tried to change all of the code so it requires a lot less code and came up with the idea of having 10 sub routines for each led. Here is the code:
This is all working and it looks great but when you get to like the 6th digit (32) it starts to take a long time to carry on. I am guessing this is because of all the sub routines then ending or some think. I am using a 20m2 chip.
Am I right in getting this working better by putting the setfreq in there? I have never used it and when I tried to put this at the start it lit one led and froze :/
Init:
setfreq 8
main:............. This didn't work etc...
Picture of the project so far:
little question is there a way of fixing this or could someone just post what to do it would be much appreciated Trevor Boultwood
Code:
main:
low 0,1,2,3,4,5,6,7,8,9
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
gosub first8
gosub first9
gosub first10
stop
first1:
high 0
pause 1000
return
first2:
low 0 high 1
pause 1000
gosub first1
return
first3:
low 0,1 high 2
pause 1000
gosub first1
gosub first2
return
first4:
low 0,1,2 high 3
pause 1000
gosub first1
gosub first2
gosub first3
pause 1000
return
first5:
low 0,1,2,3 high 4
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
pause 1000
return
first6:
low 0,1,2,3,4 high 5
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
pause 1000
return
first7:
low 0,1,2,3,4,5 high 6
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
pause 1000
return
first8:
low 0,1,2,3,4,5,6 high 7
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
pause 1000
return
first9:
low 0,1,2,3,4,5,6,7 high 8
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
gosub first8
pause 1000
return
first10:
low 0,1,2,3,4,5,6,7,8 high 9
pause 1000
gosub first1
gosub first2
gosub first3
gosub first4
gosub first5
gosub first6
gosub first7
gosub first8
gosub first9
pause 1000
return
Am I right in getting this working better by putting the setfreq in there? I have never used it and when I tried to put this at the start it lit one led and froze :/
Init:
setfreq 8
main:............. This didn't work etc...
Picture of the project so far:
little question is there a way of fixing this or could someone just post what to do it would be much appreciated Trevor Boultwood