robbyraven
New Member
Hi everyone,
I'm using the interrupt command with my 18X so that whenever pin 2 is taken high, b0=b0+1, and the new value for b0 is displayed via output 0 to a serial LCD. This is working fine, the relevant code is below:
init:
b0=0
pause 500
serout 0,N2400,(254,128) ‘ move to start of first line
serout 0,N2400,("temp diff=",#b0,"c")‘ output text
pause 1000
setint %00000100,%00000100 'interrupt when pin 2 goes high
main: etc etc....
interrupt:
b0=b0+1
pause 250
if pin2=1 then interrupt
serout 0,N2400,(254,128) ‘ move to start of first line
serout 0,N2400,("temp diff=",#b0,"c")‘ output text
setint %00000100,%00000100
pause 1000
return
So b0 starts as zero, and every time I press the button to take pin2 high, b0 increases by one and displays briefly on the LCD. However, I need to be able to do the same thing in reverse i.e. every time I press yet another button, taking another pin high, I need b0 to decrease by one. However I can't figure out how to have two different interrupt commands operative at the same time. Picaxe manual doesn't seem to shed any light on this. Can anyone tell me how to run two interrupts, or another clever way around this?
Also, I'm running out of inputs on my 18X project board. Pins 0 and 1 are analogue, 2 is taken up with my 'plus 1' switch, 3 and 4 are for serial, 5 doesn't exist and 6 and 7 are taken up with the two temperature sensors required for this project. Do I have to solder the 10k resistor across either R7 or R8? I'd rather not as the project board probably won't be the final resting place of this project.
Thanks again,
Rob
I'm using the interrupt command with my 18X so that whenever pin 2 is taken high, b0=b0+1, and the new value for b0 is displayed via output 0 to a serial LCD. This is working fine, the relevant code is below:
init:
b0=0
pause 500
serout 0,N2400,(254,128) ‘ move to start of first line
serout 0,N2400,("temp diff=",#b0,"c")‘ output text
pause 1000
setint %00000100,%00000100 'interrupt when pin 2 goes high
main: etc etc....
interrupt:
b0=b0+1
pause 250
if pin2=1 then interrupt
serout 0,N2400,(254,128) ‘ move to start of first line
serout 0,N2400,("temp diff=",#b0,"c")‘ output text
setint %00000100,%00000100
pause 1000
return
So b0 starts as zero, and every time I press the button to take pin2 high, b0 increases by one and displays briefly on the LCD. However, I need to be able to do the same thing in reverse i.e. every time I press yet another button, taking another pin high, I need b0 to decrease by one. However I can't figure out how to have two different interrupt commands operative at the same time. Picaxe manual doesn't seem to shed any light on this. Can anyone tell me how to run two interrupts, or another clever way around this?
Also, I'm running out of inputs on my 18X project board. Pins 0 and 1 are analogue, 2 is taken up with my 'plus 1' switch, 3 and 4 are for serial, 5 doesn't exist and 6 and 7 are taken up with the two temperature sensors required for this project. Do I have to solder the 10k resistor across either R7 or R8? I'd rather not as the project board probably won't be the final resting place of this project.
Thanks again,
Rob