I thought this circuit was pretty neat because it provided us with a certain amount of control. Humans like to control things, and it was pretty satisfying to be able to open and close the circuit to turn my little LED on and off at the click of a button. This simple technique will surely come in handy in this course in the future, especially in any sort of interactive installation where we may want the participants to have control over something. As far as the technicality goes, I didn't seem to have any trouble putting this one together.
Code:
' {$STAMP BS2sx} ' {$PBASIC 2.5}
' control an LED switch a switch ' using an IF..THEN structure
' ****** variables ************
mySwitch VAR BIT ' looking at a switch so only a BIT is required
' ****** setup ********
myLed CON 1 ' connect a digital out to this PIN
' **** processing ************
DO 'read the state of switch mySwitch = IN0 DEBUG ? mySwitch
' write state of switch to myLED IF mySwitch = 0 THEN LOW myLed ELSE HIGH myLed ENDIF
No comments:
Post a Comment