Bs2 help, led & servo!!
derekj032
Posts: 7
I am trying to fix my code so that I can have my servo spin 180 degree counter and also 180 clockwise along with a blinking LED Christmas tree. I can't seem to figure out what I am doing wrong in my do..loop to run these programs at the same time. My goal is to have my Christmas Tree LED's blinking separate from the indicator light , but constant while my servo program is running.
This is what I have, can someone please point me in the right direction. THANKS
counter VAR Word
PAUSE 1000
DO
HIGH 12
FOR counter = 500 TO 1000 STEP 4
PULSOUT 14, counter
PAUSE 30
NEXT
LOW 12
FOR counter = 1000 TO 500 STEP 4
PULSOUT 14, counter
PAUSE 30
NEXT
LOOP
This is what I have, can someone please point me in the right direction. THANKS
counter VAR Word
PAUSE 1000
DO
HIGH 12
FOR counter = 500 TO 1000 STEP 4
PULSOUT 14, counter
PAUSE 30
NEXT
LOW 12
FOR counter = 1000 TO 500 STEP 4
PULSOUT 14, counter
PAUSE 30
NEXT
LOOP
Comments
Rich H
If my tree has neg and pos wires why doesn't it light up when I plug it in place of the LED in p12?
More details are needed in order to make a good recommendation.
Don't try hooking up the tree directly to the stamp, you could burn out the pin - if you haven't already.
Rich H
This is the tree I am using but I am only using half, the half with the power supply connection. Instead of using the battery supply there is a + - place on the top of the tree.
All you need is an NPN transistor and a 1K ohm resistor. The pin (12?) on the BS2 would have the resistor between it and the Base of the transistor. The Source of the transistor would be connected to the negative (-) of the tree and the Drain of the transistor would connect to ground. The positive (+) of the tree would go to the 9 volt battery and the negative (-) of the 9 volt battery needs to be connected to the same ground as the transistor and BS2.
When the pin goes high on the BS2 current will flow through the transistor which will turn it "on" and complete the circuit for the tree.
Rich H
As for the lights staying on, you may want to test the BS2's pin for proper operation by hooking up a test LED and resistor. It may have been damaged earlier. Also, if you could post a picture it would help immensely.
Rich H
I will finish putting the tree on the rotating servo and post it working!
Many Thanks for your help!!!
Please explain.
Rich H
I'm glad you got it to work, I don't quite understand what you did (indicator light?) but if it is doing what you want then that is what's important. I hope you can post a video when you get it all together.
Rich H
Pin 14 is the second row.
Rich H
It looks to be connected to the same pin as the servo. A servo pulse is only 1.5 milliseconds long on average, not enough to light up the LED. Or is it? I haven't tried. At any rate, if it was visible it would be very dim and I can't see how it would be used as an indicator.
Rich H