Hi all.
I am in the process of making a POV display, a rotating Hall effect switch triggers the sequence when it passes by a magnet.
The code checks the state of the Hall input using an 'If' statement at the start of a loop, the problem is that unless the Hall switch is triggered at the same instant as the 'If' statement is executed then the sequence doesn't start, can an interupt be used in some way?
Thanks.
[/B]
I am in the process of making a POV display, a rotating Hall effect switch triggers the sequence when it passes by a magnet.
The code checks the state of the Hall input using an 'If' statement at the start of a loop, the problem is that unless the Hall switch is triggered at the same instant as the 'If' statement is executed then the sequence doesn't start, can an interupt be used in some way?
Thanks.
Code:
[B]main:
#picaxe 40X2
#no_data
let dirsA = %11111111 ' Set port A as all outputs.
let dirsB = %11111111 ' Set port B as all outputs.
let dirsD = %11111111 ' Set port D as all outputs.
SYMBOL Delay = 300
high C.1 'Blue when high.
low C.5 'Red when high.
start:
'let outpinsD = %11111111 'Turns all port D pins off
'let outpinsA = %11111111 'Turns all port D pins off
If pinc.2=0 Then 'Responds to a Hall Effect switch when connected to pin 17
let outpinsD =%11111111
' The 2 of 12
' 128 64 32 16 8 4 2 1
let outpinsA =%10011100
let outpinsA =%10111100
let outpinsA =%10111110
let outpinsA =%01111110
let outpinsA =%01111010
let outpinsA =%11100010
let outpinsA =%10001110
let outpinsA =%11111110
' This is the gap before 1.
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
' 1 for one o'clock
' 128 64 32 16 8 4 2 1
let outpinsA =%00001111
let outpinsA =%00011111
let outpinsA =%11001111
let outpinsA =%11100111
let outpinsA =%11110011
let outpinsA =%11110011
let outpinsA =%11111010
let outpinsA =%11111010
let outpinsA =%11111001
let outpinsA =%11111011
' This is the gap before 2.
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
let outpinsA =%11111111
' 2 for two o'clock.
' 128 64 32 16 8 4 2 1
let outpinsA =%10001111
let outpinsA =%10111111
let outpinsA =%00111111
let outpinsA =%10111111
let outpinsA =%11011111
let outpinsA =%11101111
let outpinsA =%11110111
let outpinsA =%11111001
let outpinsA =%11111101
let outpinsA =%11111011
let outpinsA =%11110111
let outpinsA =%11101111
let outpinsA =%11111111
Else
low C.1 'Blue when high.
high C.5 'Red when high.
let outpinsA =%11111111
let outpinsB =%11111111
let outpinsD =%00000000
End If
goto start
Last edited by a moderator: