Hello all.
I'm returning to microelectronics from a long absence, being more involved in systems of electronics than the nuts and bolts, so time to knock the rust off. I have a few projects that will be using PICAXE devices, so more questions will be following.
I've written a program for a simple controler and it works, BUT the way I would have coded it is shown in the comments.
Is there any way that it could be simplified so that it is closer to the way I would have liked to have coded it ?
Thanks in advance
I'm returning to microelectronics from a long absence, being more involved in systems of electronics than the nuts and bolts, so time to knock the rust off. I have a few projects that will be using PICAXE devices, so more questions will be following.
I've written a program for a simple controler and it works, BUT the way I would have coded it is shown in the comments.
Is there any way that it could be simplified so that it is closer to the way I would have liked to have coded it ?
Code:
'terminator program
' input sensors l_arm = input 0
' r_arm = input 1
'
' Outputs l_arm_led = output 0
' r_arm_led = output 1
' Buzzer = output 7
' l_arm_laser = output 4
' r_arm_laser = output 5
Symbol l_arm_led = 0
Symbol r_arm_led = 1
Symbol l_arm_laser = 4
Symbol r_arm_laser = 5
Symbol buzzer = 7
Symbol l_arm = b0
Symbol r_arm = b1
main:
l_arm = pin0
r_arm = pin1
if r_arm = 1 then low r_arm_laser ' }
else ' } r_arm_laser = NOT r_arm
high r_arm_laser ' }
endif ' }
if l_arm = 1 then low l_arm_laser ' }
else ' } l_arm_laser = NOT r_arm
high l_arm_laser ' }
endif ' }
low l_arm_led
low r_arm_led
if r_arm = 0 then low buzzer ' }
else ' } buzzer = NOT r_arm
high buzzer ' }
endif ' }
gosub delay
if r_arm = 1 then low r_arm_led ' }
else ' } r_arm_led = NOT r_arm
high r_arm_led ' }
endif ' }
if l_arm = 1 then low l_arm_led ' }
else ' } l_arm_led = NOT r_arm
high l_arm_led ' }
endif ' }
if l_arm = 0 then low buzzer ' }
else ' } buzzer = NOT l_arm
high buzzer ' }
endif ' }
gosub delay
goto main
delay:
pause 350