Computing.Net > Forums > Programming > Qbasic Alarm System

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Qbasic Alarm System

Reply to Message Icon

Name: Dave
Date: June 28, 2003 at 22:35:46 Pacific
OS: XP
CPU/Ram: PM4/512
Comment:

I need help with writing a qbasic program for a home alarm system built off of qbasic. I need to setup that when the alarm is activated the computer asks for a passcode, but it needs to be a timed response so the alarm sounds after no input is entered. can anyone help me??

Dave



Sponsored Link
Ads by Google

Response Number 1
Name: egkenny
Date: June 29, 2003 at 12:00:33 Pacific
Reply:

This program will do that:

DECLARE SUB SoundAlarm ()
DECLARE FUNCTION GetPassword$ ()
CLS
pasd$ = GetPassword$
PRINT
PRINT pasd$
END

FUNCTION GetPassword$
   LF$ = CHR$(10)
   CR$ = CHR$(13)
   SP$ = CHR$(32)
   DL$ = CHR$(127)
   Password$ = ""
   AlarmDelay = 5
   Timeout = TIMER + AlarmDelay
   OutOfTime% = 0
   DO
      CH$ = INKEY$
      REM Allow only prinable characters for password
      IF CH$ > SP$ AND CH$ < DL$ THEN
         PRINT "*";
         Password$ = Password$ + CH$
      END IF
      REM Out of time with no input for password
      IF TIMER > Timeout AND Password$ = "" THEN
         OutOfTime% = 1
      END IF
   LOOP UNTIL CH$ = LF$ OR CH$ = CR$ OR OutOfTime% 
= 1
   IF OutOfTime% = 1 THEN
      PRINT "Alarm Sounded !!!"
      DO
         CH$ = INKEY$
         CALL SoundAlarm
      LOOP UNTIL CH$ <> ""
   END IF
   GetPassword = Password$
END FUNCTION

SUB SoundAlarm
   FOR I% = 440 TO 900 STEP 5
      SOUND I%, I% / 1000
   NEXT I%
END SUB


0

Response Number 2
Name: Dave
Date: June 29, 2003 at 19:33:02 Pacific
Reply:

Thanks for your help. My only problem is, the alarm won't sound if input is being entered. It pauses the whole program while the input is entered. I basically need to have a timed input. Does this make any sense?

-Dave


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Please help with c on bow... Games Programming



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Qbasic Alarm System

Qbasic Alarm www.computing.net/answers/programming/qbasic-alarm/6990.html

rainstorm alarm system www.computing.net/answers/programming/rainstorm-alarm-system/15989.html

Qbasic Messaging www.computing.net/answers/programming/qbasic-messaging/7988.html