Independent LEDs

Simo7007

New Member
I've started my programming using the basic high 1, low 1, high 2, low 2 act. act. But. How can I have 2 LED's working independent, rather than;

Code:
[FONT=courier new]symbol red = 1
symbol green = 2
main:[/FONT]
[FONT=courier new]   high red[/FONT]
[FONT=courier new]   pause 1000[/FONT]
[FONT=courier new]   low red[/FONT]
[FONT=courier new]   pause 1000[/FONT]
[FONT=courier new]   high green[/FONT]
[FONT=courier new]   pause 1000[/FONT]
[FONT=courier new]   low green[/FONT]
[FONT=courier new]   pause 1000[/FONT]
[FONT=courier new]goto main
[/FONT]


EXAMPLE

Code:
[FONT=courier new]symbol red = 1
symbol green = 2
main:
 high red
 pause 250
 low red
 low green
 pause 1000
 high green
 pause 250
goto main
[/FONT]


 

inglewoodpete

Senior Member
The parallel processing of the M2-series PICAXEs is one option that makes it simpler. However, you can be the following on any PICAXE chip (old or new).

There is no reason why you can't turn LEDs on or off in different loops. Try this in the simulator or a real PICAXE
Code:
Symbol Red = 1
Symbol Green = 2

Do
   For b1 = 1 to 9
      Select Case b1
      Case 1, 3, 5
         High Red
      Case 2, 7, 9
         Low Green
      Case 4, 6, 8
         Low Red
         High Green
      EndSelect
      Pause 100
   Next b1
Loop
For a more sophisticated piece of code, have a look at this posting I last updated about a year ago. If you have an AXE092 School's Experimenter board, give it a try.
 

westaust55

Moderator
Also for the M2 parts, there is the system variable Time which has incrementing elapsed time that could be used.
See PICAXE manual 2 (V7.9) page 13 to 15
 
Top