Tuesday, October 7, 2008

Touch Sensor Prototype 2: 2 Touch

Lisa Ekle, Pierre Gerlier, Keith Greenwald, Michael Walch


In this prototype we used 2 piezo sensors as input to turn on/off a single LED. Both sensors must be touched to turn on the LED.


Script:

' {$STAMP BS2}
' {$PBASIC 2.5}
TriggerPin0 PIN 0 ' Pin that gets the touch sensor input
TriggerPin1 PIN 2
TriggerCount VAR Byte

Main:
LOW 15
TriggerCount = 0
IF TriggerPin0 = 1 THEN TriggerCount = TriggerCount + 1 ' Check pin0, add to counter
IF TriggerPin1 = 1 THEN TriggerCount = TriggerCount + 1 ' Check pin0, add to counter
DEBUG "sensor 0:", DEC TriggerPin0, CR
DEBUG "sensor 1:", DEC TriggerPin1, CR
DEBUG "count: ", DEC TriggerCount, CR
IF TriggerCount >= 2 THEN ledOn ' Check number of sensors on
DEBUG "off", CR ' else show off
PAUSE 1000
GOTO Main ' loop

ledOn:
DEBUG "ledOn Called", CR
HIGH 15 ' turn on led/flex attached to pin 15
PAUSE 2000
GOTO Main

Labels: ,


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?