Shop OBEX P1 Docs P2 Docs Learn Events
Monitor clock while getting DEBUGIN or SERIN input ? — Parallax Forums

Monitor clock while getting DEBUGIN or SERIN input ?

berniebernie Posts: 2
edited 2004-10-16 10:18 in Learn with BlocklyProp
Is there a way to decrement a clock timer or otherwise monitor the passage of time, while simultaneously waiting for SERIN or DEBUGIN input?

I ask because the final assignment in "What's a Microcontroller" (project 4 on p. 290 of edition 2.1) specifies a security sensor system that requires a password to be input within a 30-second interval in order to prevent sounding of an alarm.

How can this lesson be completed? (You could skip SERIN/DEBUGIN in favor of a hard-wired keypad, but I don't think that's the sense of the chapter in this book.)

Comments

  • AllanL5AllanL5 Posts: 12
    edited 2004-09-15 15:21
    The SERIN does have a time-out value, so you could set that for 30 seconds.
    If nothing comes in during that time, the resulting variable string will start with a 'null' (CHR(0)) character.
  • edited 2004-09-16 17:03
    Hi Bernie,

    I took a different approach, since it is·difficult to monitor the passage of time.

    Here's what the problem said:
    "When the alarm is armed and a pushbutton is pressed and released, the piezo speaker should send out brief warning chirps every five or ten seconds for thirty seconds.· If the correct password has not been entered after 30 seconds, the piezospeaker should make a continuous loud and annoying noise."

    I figured it didn't say you had to sit there and wait 30 seconds continuously ;-)... so...

    I just checked the password every 5 seconds, and counted how many 5-second intervals had happened.· If it got to 30 seconds, and the correct password had not been entered, then I broke out of the loop (with a GOTO) to a routine that made a loud, annoying noise.· I wrote a routine called Check_Password_Once that just checked the password once.· It did not loop until the correct one was entered, it just asked for the password, stored what was entered, and then RETURNed.



    Cheers,

    Kris Magri
    Parallax, Inc.



    ·
  • berniebernie Posts: 2
    edited 2004-10-16 10:18
    Barring an external clock to consult, Kris's approach comes the closest I could imagine to a real-world system.

    If you use the SERIN command (not documented in the "What's a Microcontroller" book), you can put in a timeout value.
    The only thing I didn't like about it is that there's no way to obscure the password as it's being typed in. (The one-character-at-a-time
    input method allows you to backspace and cover up the just-input character with an asterisk.)
Sign In or Register to comment.