Problems
LiverEatnJohnson
Posts: 1
I am having a problem with this code. the servo opens and closes the door but when i uncomment the GOSUB detect_intruders it wont stop beeping or open the door it gets stuck in the loop any help would be great thanks in advance.
''''''''''''''''''''''''''''''''''''''Comapny: MAGi iNDUSTRIES iNC. 'Programmer: Jeremiah Johnson 'Project: MagiIndustriesSecurity 'File: SecutirySystem.bs2 'Assingment: Final Digital Systems 'Date: Dec 7th 2011 ''''''''''''''''''''''''''''''''''''' ' {$STAMP BS2} ' {$PBASIC 2.5} ''/ 'This is a single door locking system with time keeping from door lock. 'Records up to 1500 events. 'Feturing an offensive and alertive sonic subroutine for debilitating intruders. 'With single touch activation and simple event retrival. ''/ ''''''Activation{ ' Push buttom button to Lock door. ' door will lock arming the sonic subroutine and recording the event ' if an intruder is detected vai the phototransducer ' sonic subroutine fires and the evnt is recorded ' Push top button to Open door ' event is recorded ' door unlocks and sonic subroutine disarmed ''''''} ''''''Event_Retirval{ '1. Remove power from module '2. Connect module to your computer '3. Run Paralax BASIC Stamp Editor '4. Load SecurityRetirval.bs2 into the text window '5. Reconnect power to the module '6. Before 6 seconds pass run the program '7. Events will be displayed in the debug window ''''''} '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' '' Variables '' lckBtn VAR IN0 unlkBtn VAR IN1 open VAR Bit detect VAR Word intruder VAR Bit seconds VAR Word minutes VAR Word hours VAR Word days VAR Word address VAR Word '' Main Program '' DO ''lock door IF(lckBtn = 1) THEN open = 0 GOSUB lock_door 'GOSUB detect_intruder 'GOSUB clock_start 'GOSUB record_event ELSEIF(unlkBtn = 1) THEN ''open door LOW 15 LOW 9 open = 1 GOSUB open_door 'GOSUB record_event ENDIF '' loop forever LOOP ''''''''''''''''''''''''''''''''''''''''''''''''' Funcutions ''''''''''''''''''''''''''''''''' '' 'locks the door '' lock_door: DEBUG "locking door", CR PULSOUT 2, 250 RETURN '' 'opens the door '' open_door: DEBUG "unlocking door", CR PULSOUT 2, 1250 RETURN '' 'detects intruders '' detect_intruder: HIGH 15 DO WHILE (open = 0) PAUSE 100 RCTIME 15, 1, detect DEBUG DEC detect, CR '' is there an intruder IF (detect > 4000) THEN 'intruder detected FREQOUT 9, 1500, 2000 DEBUG "intruder detected", CR intruder = 1 'GOSUB record_event ELSE 'no intruder do nothing ENDIF LOOP RETURN '' 'records time '' clock_start: ''set variables seconds = 0 minutes = 0 hours = 0 days = 0 'start timer DO PAUSE 1000 seconds = seconds + 1 IF (seconds = 60) THEN minutes = minutes + 1 seconds = 0 ENDIF IF (minutes = 60) THEN hours = hours + 1 minutes = 0 ENDIF IF (hours = 24) THEN days = days + 1 hours = 0 ENDIF LOOP 'stop timer RETURN '' 'recorces events '' record_event: DO WHILE address <= 3000 WRITE address, Word open address = address + 2 WRITE address, Word intruder address = address + 2 WRITE address, Word days address = address + 2 WRITE address, Word hours address = address + 2 WRITE address, Word minutes address = address + 2 WRITE address, Word seconds address = address + 2 LOOP RETURN ''''''''''''''''''''''''''''''' End ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Comments