Using potentiometer to increase/decrease blinking rate of LED
Hi everyone, I'm trying to use a pot to increase/decrease blinking rate of LED. To do this I have tried modifying activity 4 from chapter 7 of 'what's a micro controller' with some success.
Originally it was a light meter test that speeds-up and slows-down the lights of a 7-segment LED display depending on how bright it was in a room.
Now I have substituted a potentiometer for the phototransitor and a single LED instead of the 7 segment one. For the Pot, I've used a .1 uF capacitor and a 220 Ohm resistor (Plugged into P7) . For the LED I've used a 470 Ohm resistor (plugged into P15). I think the light isn't as bright when the pause values are set lower (i.e. high/low pause = 5 vs 50). Would this be because of the capacitor?
You can mess around with the time values too... I don't know if that will affect the brightness of the LED too.
Anyway I just thought I'd throw this out there if anyone wanted to improve it or use it.
Originally it was a light meter test that speeds-up and slows-down the lights of a 7-segment LED display depending on how bright it was in a room.
Now I have substituted a potentiometer for the phototransitor and a single LED instead of the 7 segment one. For the Pot, I've used a .1 uF capacitor and a 220 Ohm resistor (Plugged into P7) . For the LED I've used a 470 Ohm resistor (plugged into P15). I think the light isn't as bright when the pause values are set lower (i.e. high/low pause = 5 vs 50). Would this be because of the capacitor?
You can mess around with the time values too... I don't know if that will affect the brightness of the LED too.
Anyway I just thought I'd throw this out there if anyone wanted to improve it or use it.
' {$STAMP BS2} ' {$PBASIC 2.5} PAUSE 1000 time VAR Word ' Variable declarations DO ' main routine GOSUB Get_Rc_time GOSUB Delay GOSUB Update_display LOOP Get_Rc_time: ' RC-Time Subroutine HIGH 7 PAUSE 100 RCTIME 7, 1, time DEBUG HOME, "time = ", DEC5 time RETURN Delay: ' Delay Subroutine PAUSE time /2 RETURN Update_display: 'Diplay updating subroutine HIGH 15 PAUSE 20 LOW 15 PAUSE 20 RETURN
Comments
Which pauses are you talking about? A smaller capacitor would reduce the time it takes to discharge the RC circuit, but that would only change the Delay subroutine. If you change the pause in the Update_Display subroutine, then that will control how long the LED is on for each pulse. By changing the pause here you will make it appear to be brighter/dimmer, as long as the pause is "small". By small, I mean so that the program executes fast enough where the eye doesn't see the LED turn on and off, it all blends together.
But in any case, you are trying to change the blinking rate. Normally RC circuits have a pretty small time constant. You can calculate the constant in your circuit, or just look and see what the DEBUG statement returns then find the units (look in the reference manual). Assuming that I'm not crazy, then this is probably a rather small number. I'd multiply it instead of divide it in the Delay routine in order to get a more noticeable blinking range.
I didn't really use the formula for the offset because when I did, the lights didn't blink quickly enough for what i wanted to do when it was set to full speed.
Does it work? ...