Report Bugs Here

Moderator: Mmiscool

User avatar
By Mmiscool
#63311 You can have interupts on any of the i/o pins and there is no limit to how many you can have except the number of pins available. One interrupt per pin.

I will look at this code as soon as i get gome but i have a feeling you are not debouncing your input.
User avatar
By Mmiscool
#63313 The following code shows how to debouce an interrupt pin. The interrupt will fire when the pins status changes so for each button press the interrupt will fire twice. Once when you press the button down and again when you release the button. The io(laststat, x) will tell you the status of the pin when the interrupt was fired.

Code: Select allinterrupt 0, [mybranch]
wait

[mybranch]
if io(laststat,0) = 1 then wait
print "interrupt triggered"
wait
User avatar
By Electroguard
#63326
You can have interupts on any of the i/o pins and there is no limit to how many you can have except the number of pins available

That's some surprisingly useful info, and possibly worthwhile adding to the docs.
User avatar
By Miloit
#63423 Thanks Mike ! I have compiled the program with debounce and all work very well. Web buttons and physical buttons work ok :D .
Code: Select allmemclear
a = 1
b = 1
r1 = 16
r2 = 3
ciclo = 1
dimmer = 0
t1 = 1000
t2 = 2000
io(po,r1,1)
io(po,r2,1)
interrupt 14,[inta]
interrupt 12,[intb]
interrupt 13,[intc]
interrupt 5,[intd]

wprint "Out A (On/Off) "
wprint htmlvar(a)
button "On", [Aon]
button "Off", [Aoff]
wprint "<br><br>"
wprint "Out B (On/Off) "
wprint htmlvar(b)
button "On", [Bon]
button "Off", [Boff]
wprint "<br><br>"
wprint "Out A and B (Cilic) A "
wprint htmlvar(a)
wprint " B "
wprint htmlvar(b)
button "On", [ciclic]
wprint "<br><br>"
wprint "Dimmer C "
wprint htmlvar(dimmer)
button "On", [dimm]
wprint "<br><br>"
wait

[Aon]
io(po,r1,0)
a = 0
gosub [status]
returngui
wait

[Aoff]
io(po,r1,1)
a = 1
gosub [status]
returngui
wait

[Bon]
io(po,r2,0)
b = 0
gosub [status]
returngui
wait

[Boff]
io(po,r2,1)
b = 1
gosub [status]
returngui
wait

[ciclic]
if ciclo = 0 then
io(po,r1,1)
a = 1
io(po,r2,1)
b = 1
ciclo = 1
gosub [status]
returngui
wait
end if

if ciclo = 1 then
io(po,r1,0)
a = 0
io(po,r2,1)
b = 1
ciclo = 2
gosub [status]
returngui
wait
end if

if ciclo = 2 then
io(po,r1,1)
a = 1
io(po,r2,0)
b = 0
ciclo = 3
gosub [status]
returngui
wait
end if

if ciclo = 3 then
io(po,r1,0)
a = 0
io(po,r2,0)
b = 0
ciclo = 0
gosub [status]
returngui
wait
end if
wait

[inta]
if io(laststat,14)= 1 then wait
if a=0 then
io(po,r1,1)
a = 1
else
io(po,r1,0)
a = 0
endif
gosub [status]
returngui
wait

[intb]
if io(laststat,12)= 1 then wait
if b=0 then
io(po,r2,1)
b = 1
else
io(po,r2,0)
b = 0
endif
gosub [status]
returngui
wait

[intc]
if io(laststat,13)= 1 then wait
if ciclo = 0 then
io(po,r1,1)
a = 1
io(po,r2,1)
b = 1
ciclo = 1
gosub [status]
returngui
wait
end if

if ciclo = 1 then
io(po,r1,0)
a = 0
io(po,r2,1)
b = 1
ciclo = 2
gosub [status]
returngui
wait
end if

if ciclo = 2 then
io(po,r1,1)
a = 1
io(po,r2,0)
b = 0
ciclo = 3
gosub [status]
returngui
wait
end if

if ciclo = 3 then
io(po,r1,0)
a = 0
io(po,r2,0)
b = 0
ciclo = 0
gosub [status]
returngui
wait
end if
wait

[intd]
wait

[dimm]
pwo
wait

[status]
'print "A " & a & " B " & b & " D " & dimmer

return

[Exit]
end