Fade Using PWM command with the BASIC Stamp
RonK
Posts: 7
Hello. I am a new member trying to write a Program and breadboard the electronics for my Basic Stamp, and I need some help. Any suggestions would be greatly appreciated. This is what I need to do.
I need to control fading of analog voltages on 2 pins at the same time.
This is an example. I have been able to use the PWM command to put a voltage of 2 volts on Pin 12 and at the same time a voltage of 2.5 volts on pin 13. Then using the PWM command I can abruptly change the voltage to 2.5 volts on Pin 12 and 2.0 volts on Pin 13.
What I would like to do is have them fade simultaneouly from the first state to the second state over time period of about 1 second. As an example, fade simultaneously from (2V Pin 12, 2.5V Pin 13) to (2.5V Pin 12, 2.0V Pin 12) over a time of about 1 second.
Any suggestions on how to do that? Or is there a better way to do it other than the PWM command.
If I can figure out that specific example, then I can figure out the more general case.
Thanks ahead of time.
Ron
I need to control fading of analog voltages on 2 pins at the same time.
This is an example. I have been able to use the PWM command to put a voltage of 2 volts on Pin 12 and at the same time a voltage of 2.5 volts on pin 13. Then using the PWM command I can abruptly change the voltage to 2.5 volts on Pin 12 and 2.0 volts on Pin 13.
What I would like to do is have them fade simultaneouly from the first state to the second state over time period of about 1 second. As an example, fade simultaneously from (2V Pin 12, 2.5V Pin 13) to (2.5V Pin 12, 2.0V Pin 12) over a time of about 1 second.
Any suggestions on how to do that? Or is there a better way to do it other than the PWM command.
If I can figure out that specific example, then I can figure out the more general case.
Thanks ahead of time.
Ron
Comments
If you have two pins, you'd need "stepSize2 = (endValue2 - startValue2) / numberOfSteps"
and, in the loop, you'd need "pwm pinNumber2, startValue2 + (stepSize2 * i)"
Thanks. That's very helpful. I'll try it over the weekend.
...ron