Shop OBEX P1 Docs P2 Docs Learn Events
three questions on BS2 — Parallax Forums

three questions on BS2

mzwdmzwd Posts: 3
edited 2007-01-05 14:40 in BASIC Stamp
First, my project is to control a·lamp level depending on the light in the room using light sensor wirelessly
so on the receiving part i use BS2 and get the transmited signal using wireless receiver then take an output
to the lamp

this is the code of the receiver

'{$STAMP BS2}
' {$PBASIC 2.5}
datas VAR Byte
i VAR Byte
check:
SERIN 7, 16780, [noparse][[/noparse]WAIT("*!"), DEC2 datas]
PAUSE 300
DEBUG DEC2 datas, CR

IF datas = 1 THEN one
IF datas = 2 THEN two
IF datas = 3 THEN three
IF datas = 4 THEN four
IF datas => 5 THEN five
one:
DEBUG "Level 1", CR
FOR i = 0 TO 5
PWM 4,255,255
NEXT
GOTO check
two:
DEBUG "Level 2", CR
FOR i = 0 TO 5
PWM 4,191,255
NEXT
GOTO check
three:
DEBUG "Level 3", CR
FOR i = 0 TO 5
PWM 4,127,255
NEXT
GOTO check
four:
DEBUG "Level 4", CR
FOR i = 0 TO 5
PWM 4,63,255
NEXT
GOTO check
five:
DEBUG "Level 5", CR
FOR i = 0 TO 5
PWM 4,0,255
NEXT
GOTO check

but i have three problems:
1-the BS2 can't switch on a 2.5V lamp but it do with LED , is because the output current is very small (20mA)??? if it is what is the solution??
2-the LED is blinking··how can i let it work continuesly (because of the FOR loop)??
3-how to let the lamp work continuesly until the level is changed

·i already use voltage·amplifier but make no difference

Comments

Sign In or Register to comment.