This is my first Basic Stamp 2 Project. I control a Tri - Color LED by typing the letter of the color (G or B). I couldn't use the red color because i didn't have the proper resistor...
Oh and the Basic Stamp 2 Micro controller is made by PARALLAX Inc.
Circuit Diagram :
http://img241.imageshack.us/img241/9060/ledd.jpg
NOTE: The resistor depends on the led you're using. To calculate the necessary resistor go to this webpage:
http://metku.net/index.html?sect=view&n=1&path=mods/ledcalc/index_eng...
Code :
' {$STAMP BS2}
' {$PBASIC 2.5}
Dat VAR Word ' Make a Variable called Dat
LOW 2
LOW 3
DO ' Start a loop.
DEBUGIN Dat ' Write the letter typed on the terminal to the variable.
IF Dat = "g" THEN ' Wait for g being typed
LOW 2
HIGH 3 ' If so, put pin 3 on high, which will turn the led Green.
DEBUG "LED Is now green." ,CR 'Indicate that the led is green.
ELSEIF Dat = "b" THEN ' Wait for b being typed.
LOW 3
HIGH 2 ' If so, put pin 2 on high which will turn the LED Blue.
DEBUG "LED Is now blue." ,CR ' Indicate that the led is blue
ELSE
ENDIF
LOOP ' End the loop.
You know if u get some variable resistors, you can make any color.
TheBasicStamp 1 year ago
@TheBasicStamp you can also use a digital pot to fade between the colors
xXjose130Xx 8 months ago