Did you used a delayer-based timer in the first version?
It's not reliable... it stops after a game restart...
Why did you don't use red plants, they generate an interrupt every 3 seconds!
And why do you need a
hardware timer?
Here's my improved code, it does not need any hardware timer.
Port D is used as alarm output if the password is wrong.
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
digiline_send("keyboard","Please enter password:") -- change keyboard message
if event.type=="interrupt" then -- timer expired
port.c=true -- close door
port.d=false -- disable alarm output
elseif event.type=="digiline" and event.channel=="keyboard" then
if event.msg=="password" then
-- correct password
digiline_send("printer","Log: correct password") -- adding timestamp with RTC?
port.c=false -- open door
interrupt(5) -- schedule closing after 5 seconds
else
-- wrong password
digiline_send("printer","Log: wrong password "..event.msg) -- also include wrong password
port.d=true -- output alarm signal
interrupt(3) -- schedule alarm off after 3 seconds
end
end
Sorry for the very long while waiting for JTAG, I'm doing heavy bugfixing...
(And working on
Javascript and
Lua for my DIY embedded system in a cardboard box... basically a luacontroller in real life, and kept in a cardboard box together with crappy LCD monochrome display, 4x4 keypad, Wi-Fi chip and some batteries).