dimming a led
guydb
Posts: 29
hi,
any suggestions as to how to dim a led with the stamp?
thanks,
guy
any suggestions as to how to dim a led with the stamp?
thanks,
guy
Comments
Regards,
Mike
Unfortunately, the Stamp can't do anything else while it's executing the PWM statement, but you could do other
brief things as long as your program spends most of its time doing the PWM.
Here's one example of a program that does LED fading with some motor control: http://forums.parallax.com/showthread.php?p=682581.
Read the Basic Stamp 1 application note "Fun With Trains" application 21.
It is a very cleaver way of creating a continuous PWM signal within a loop.
The application outputs three (3) unique PWM signals Continuously to modulate three (3) electric train motors.
If you create an 8 bit byte variable, and add a duty cycle of 0 to 255 (0% to 100%) to itself in a loop, output the variable.bit8 to a pin, clear variable.bit8 to 0, you will have created a continuous PWM signal. The higher the duty cycle, the more times variable.bit8 will be a logic 1.
http://www.parallax.com/dl/appnt/stamps/bs1Appnotes.pdf
Also read this application from EME System. The code mimics the Parallax PWM statement.
http://www.emesystems.com/BS2PWM.htm.
Stephen J Wagner
You can insert several the·code examples from the Trains application note or from EME systems into your code that is allready running. However, at some point the LEDs may start to flicker. Insert more examples as required.
SJW
but in the end I think I have my solution (I should have mentioned that I was looking for optocoupling, controlling the leds from the stamp and needing various levels of brightness), I will use 74HC595's and have the number of leds lit to take care of brightness (ok, only 8 per 74, but working with colour combinations and positioning towards the LDR might give more gradation).