Basic stamp 2 light dimmer
Emery Wayman
Posts: 18
Need help programming Basic Stamp 2 to slowly stairstep light on to bright, then bright to off in a continuous loop.
Comments
i.e.
That should start the LED dimly and brighten it... play around with that and maybe a pause after the PULSOUT.
-Tristan
Emery
Is this for a class?
-Tristan
No, not for a class. Actually I am working on light for color therapy that I want to experiment with.
-Emery
This solution may not be suitable for color therapy as it causes the light to flicker, but if you have a basic stamp in front of you you can give this a try. I wired Pin14 to a 470ohm resistor to an led to Vss, and ran:
The idea is that to dim the LED you simply have it off much longer than you have it on. So at the beginning of the loop when i = 0, you turn on the LED, pause for 1 millisecond and then turn it off for 10ms. Then it repeats this 9 more times before turning the LED on for 2ms and turning it off for 10.
If this is not smooth enough you can get smaller pauses using a PULSOUT function, but give this a try first.
If you have more questions about how to power LEDs using the BasicStamp, you might want to look at Chapter 2 of the "What is a Microcontroller" book here: www.parallax.com/dl/docs/books/edu/wamv2_2.pdf
If the code above gives you the behavior that you are looking for I can help you edit it to have the LEDs behave to your specifications.
(sorry about the student question, I'm happy to help anybody, but I didn't want to do somebody's homework or something.)
-Tristan
Post Edited (Tristan T) : 6/12/2006 9:02:07 PM GMT
I do have a Basic Stamp in front of me but the problem is, my wife threw out my books and USB connecting cable and program out about 3 weeks ago. Now I have to order all new stuff to go on with my project. When I get it, I will instal the program that you sent and let you know if it works like I want it to. Thank you very much for taking the time to help me out.
Question. The Stamp I have, has a program code on it that seems to work OK for what we are trying to do. When I get the new stuff, can I access the program that is already on my present Stamp with the Stamp editor?
Emery
Sadly, the program stored on your stamp is gone once you reprogram it and there is (almost) no way to get it back. There is someone who at one point offered a program recovery service, but it required that you mail in your basic stamp and i'm sure wasn't cheap. Hopefully it won't be too hard to recreate.
Once you have your basic stamp up and running again, feel free to post again, or private message me for any help.
-Tristan
Ryan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Ryan Clarke
Parallax Tech Support
RClarke@Parallax.com
Emery
I tried the revision of the program that you sent. It doesn't work nearly as good as the original one you sent, so I downloaded the original program back to my BS2 and hooked it up to my DC Relay with 12 volts to a 12 vold light. The incandecent light goes on and off slow like the LED does but I can see the flicker and it cycles too fast. How and where would I use the PULSOUT command so it didn't flicker so much. Maybe we could just slow the cycle down a little less too. Thankyou much.
Emery