Hello all,
I was wondering if anyone could give me some advice/help with my coding? I brought a beginners pic and download cable along with the download board a couple of weeks ago after a friend referred me to learn picaxe, he said it is more efficient than using unnecessary components with the bog standard timing chips. So far I have read through the whole of manual 1 and 2 (the pages that correspond to the 08m chip.) my first little project I set myself was to make a 3 letter word out of LED’s where I timed it so one letter would light up and then the second letter would light up and then the third would light up then repeat itself.
Moving more onto the point of my question, I want to make a little advance on my little project by putting it in modes. 3 mode’s if possible.
The components I am going to use are:
• A small SPST switch (push to make button)
• 08m Picaxe
• 4.5v power supply
• LED’s for the first letter
• LED’s for the second letter
• LED’s for the third letter
• A LED to show what number mode the projects in
• 330 Ohm Resistors... so the LED’s do not burn out on me
The LED to show what mode my project is in will light up while in mode 1, when the project has been put in mode 2 the LED will flash twice and stay high, and when in mode 3 the LED will flash 3 times and stay high.
Here is the original code without the modes:
And here is what I though the code should look like with modes:
The only problem with the code above that I have noticed is you have to hold down the push to make button and wait for it to change modes and if you hold it down for too long it goes into the next mode.
I have read up on the forum that setint with an interrupt is a good way to check for button presses, however when reading page 180+ (I think) on the setint commands I can’t seem to get my head around how I can incorporate it within my program.
I have also attached a schematic of what my project should look like. (I have used one LED on each output on the schematic instead of using 50 )
Thanks for taking your time to have a look and for the reply’s if any
I was wondering if anyone could give me some advice/help with my coding? I brought a beginners pic and download cable along with the download board a couple of weeks ago after a friend referred me to learn picaxe, he said it is more efficient than using unnecessary components with the bog standard timing chips. So far I have read through the whole of manual 1 and 2 (the pages that correspond to the 08m chip.) my first little project I set myself was to make a 3 letter word out of LED’s where I timed it so one letter would light up and then the second letter would light up and then the third would light up then repeat itself.
Moving more onto the point of my question, I want to make a little advance on my little project by putting it in modes. 3 mode’s if possible.
The components I am going to use are:
• A small SPST switch (push to make button)
• 08m Picaxe
• 4.5v power supply
• LED’s for the first letter
• LED’s for the second letter
• LED’s for the third letter
• A LED to show what number mode the projects in
• 330 Ohm Resistors... so the LED’s do not burn out on me
The LED to show what mode my project is in will light up while in mode 1, when the project has been put in mode 2 the LED will flash twice and stay high, and when in mode 3 the LED will flash 3 times and stay high.
Here is the original code without the modes:
Code:
main:
high 0
pause 1500
high 1
pause 1500
high 2
pause 1500
low 0,1,2
pause 1500
goto main
Code:
led_for_mode_1:
high 4
if pin3 = 1 then goto mode1
Mode1:
high 0
pause 1500
high 1
pause 1500
high 2
pause 1500
low 0,1,2
pause 1500
if pin3 = 1 then goto led_for_mode_2
goto Mode1
led_for_mode_2:
high 4
pause 100
low 4
pause 100
high 4
if pin3 = 1 then goto mode2
Mode2:
high 0
pause 500
low 0
high 1
pause 500
low 1
high 2
pause 500
low 2
if pin3 = 1 then goto led_for_mode_3
goto mode2
led_for_mode_3:
high 4
pause 100
low 4
pause 100
high 4
pause 100
low 4
pause 100
high 4
if pin3 = 1 then goto mode3
Mode3:
high 0,1,2
pause 250
low 0,1,2
pause 250
if pin3 = 1 then goto led_for_mode_1
goto mode3
I have read up on the forum that setint with an interrupt is a good way to check for button presses, however when reading page 180+ (I think) on the setint commands I can’t seem to get my head around how I can incorporate it within my program.
I have also attached a schematic of what my project should look like. (I have used one LED on each output on the schematic instead of using 50 )
Thanks for taking your time to have a look and for the reply’s if any
Attachments
-
14.3 KB Views: 23