The dual relay uses a ground to energize the relays. I recommend to modify the circuitry so a positive voltage from the module energizes it instead.
Thanks to cicciocb for the keyboard example.
This project can cause catastrophic damage and/or DEATH if not done correctly. Do this at your own risk. This is NOT recommended for the hobbyist.
Code: [Local Link Removed for Guests]
'skidsteer
PIN.MODE 4, INPUT ' wakes up module
PIN.MODE 17, OUTPUT 'ignition power
PIN.MODE 16, OUTPUT 'starter crank
PIN.MODE 18, OUTPUT 'acknowledgement buzzer
PIN(16)= 0
PIN(17)= 0
PIN(18)= 0
count = 0
crank = 0
ignition = 0
timr = 0
line$ = ""
k$ = ""
kp$ = ""
dim rows(4) = 26, 25, 33, 32
dim cols(4) = 35, 34, 39, 36
dim sym$(16) = "1", "2", "3", "A", "4", "5", "6", "B", "7", "8", "9", "C", "*", "0", "#", "D"
for z = 0 to 3 ' set the pins as input and output
pin.mode rows(z), output
pin.mode cols(z), input, pulldown
pin(rows(z)) = 0
next z
k$ = ""
Kp$ = ""
timer1 60000, wifioff 'wifi off in 1 minute after start
OPTION.WDT 3000
do
scan k$
if (k$ <> kp$) and (k$ <> "") then
line$ = line$ + k$
count = count + 1
gosub shortbp 'acknowledge key press
print line$
end if
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx my code v
if line$ = "####" then reboot 'reboots processor
if line$ = "2345" then ' lock code is 2345
ignition = 1
PIN(17)= 1
print "ignition on"
gosub threebp 'ignition success
endif
if line$ = "1234" then ' lock code is 1234
ignition = 1
PIN(17)= 1
print "ignition on"
gosub threebp 'ignition success
endif
if (count > 3)and(ignition = 0) gosub longbp 'long beep for error
if count > 3 then 'limits the code attempt to 4 digits
line$ = ""
count = 0
endif
if (line$ <> "")and(line$ <> "*")and(ignition = 1) then 'engine kill
OPTION.WDT 0
ignition = 0
PIN(17)= 0
count = 0
line$ = ""
print "engine kill"
gosub sleeep
endif
if (ignition = 1)and(k$ = "*") then pin(16)= 1 else pin(16)=0 'cranking
pause 100
if pin(16) = 1 print "cranking"
if (ignition = 0)and(timr = 0) then
timer0 180000, sleeep 'sleeps after 3 min of ignition off
timr = 1
endif
if ignition = 1 then
timer0 0
timr = 0
endif
kp$ = k$
pause 10
option.WDTreset
loop
sleeep: 'sleep after 1/2 hour of no ignition
print "sleeping"
pause 1000
SLEEP 31536000, 4, 2 'choose pin and state forever,pin 4, wake when top row of keyboard pressed
Pause 100
return
shortbp: 'acknowledge
PIN(18)= 1
print "beep"
pause 50
PIN(18)= 0
return
longbp: 'error
PIN(18)= 1
print "beeeeeeep"
pause 1000
PIN(18)= 0
return
threebp: 'success
PIN(18)= 1
print "beep beep beep"
pause 50
PIN(18)= 0
pause 50
PIN(18)= 1
pause 50
PIN(18)= 0
pause 50
PIN(18)= 1
pause 50
PIN(18)= 0
pause 50
PIN(18)= 1
pause 50
PIN(18)= 0
return
wifioff:
wifi.sleep
return
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx my code ^
sub scan(key$)
local r, c, l, code
code = -1
for r = 0 to 3
pin(rows(r)) = 1
for c = 0 to 3
l = pin(cols(c))
if (l=1) then
code = r*4 + c
exit for
end if
next c
pin(rows(r)) = 0
if (code <> -1) then exit for
next r
if (code <> -1) then key$ = sym$(code) else key$ = ""
end sub