3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Garage Monitor 3k

Step 3Now that it works on your breadboard...

You should probably program the bs2, here is the code. Most of this code is closely based on examples in the various PDF available on the parallax site. You pay more for the BS2, but the documentation is great.

' {$STAMP BS2}
' {$PBASIC 2.5}
'

' -----( I/O Definitions )-------------------------------------------------

PIR PIN 0 ' I/O Pin For PIR Sensor
LEDONE PIN 15 ' I/O Pin For Green LED
LEDTWO PIN 14 ' I/O Pin For Red LED

' -----( Variables )-------------------------------------------------------

counter VAR Byte ' Trip Counter
x VAR Word ' define a general purpose variable
sign VAR x.BIT15 ' sign bit of x
degC VAR Word ' define a variable to hold degrees Celsius
degF VAR Word ' to hold degrees Fahrenheit

' -----( Initialization )--------------------------------------------------

DEBUG CLS ' Clear DEBUG Screen
SEROUT 12,396,("!NB0W07:", "Warming Up",CLS) 'Tell the PINK whats up
FOR counter = 10 TO 0
HIGH LEDONE ' Flash the LEDS
LOW LEDTWO ' Wait 20 Seconds For PIR Warm-Up
DEBUG HOME, "Warming up:", DEC2 counter
SEROUT 12,396,("!NB0W07:Warming up:", CLS)
PAUSE 1000
LOW LEDONE
HIGH LEDTWO
PAUSE 1000 ' Display Counter Every Second
NEXT
LOW LEDONE
LOW LEDTWO

counter = 0 ' Clear Counter Variable

DEBUG HOME, "Waiting"
SEROUT 12,396,("!NB0W07:Waiting...", CLS)
HIGH LEDTWO

HIGH 5 ' select the DS1620
SHIFTOUT 7,6,LSBFIRST,(238) ' "start convertions" command
LOW 5 ' do the command

' -----( Program Code )----------------------------------------------------

Main:
DO
'Motion detector
IF PIR = 1 THEN ' Motion Detected?
counter = counter + 1 ' Update Trip Counter
HIGH LEDONE '
LOW LEDTWO ' Light Red LED
DEBUG HOME, "TRIPPED...", DEC3 counter
SEROUT 12,396,("!NB0W07:", "Tripped...",CLS)
DO : LOOP UNTIL PIR = 0 ' Wait For PIR To Clear
DEBUG HOME, "CLEARED...", DEC3 counter
SEROUT 12,396,("!NB0W07:", "Cleared...",CLS)
LOW LEDONE
HIGH LEDTWO ' Turn Off Red LED
ENDIF

'Temperature
HIGH 5 ' select the DS1620

SHIFTOUT 7,6,LSBFIRST,(170) ' send the "get data" command
SHIFTIN 7,6,LSBPRE,(x\9) ' get the data, including sign
LOW 5 ' end the command
x.BYTE1 = -x.BIT8 ' extend the sign to 16 bits
degC=x*5 ' convert to 'C*10 (resolution 0.5 'C)
degF= degC+2732*9/50-459 ' conver to F
DEBUG ? degF, CR, CR ' Show on debug
SEROUT 12,396,("!NB0W06:", DEC degF ,CLS)

'Garage Door detector.
IF IN1 = 0 THEN
SEROUT 12,396,("!NB0W08:", "Open" ,CLS)
ELSE
SEROUT 12,396,("!NB0W08:", "Closed" ,CLS)
ENDIF

PAUSE 1000

LOOP
« Previous StepDownload PDFView All StepsNext Step »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
102
Followers
70
Author:joe
I like to tinker with just about anything, sometimes it works out in the end. Have fun looking at the projects, try tearing something open and let me know how it goes. cheers, -Joe