I want to use an MCU to make an LED get brighter and dimmer (not just blink on and off). Specifically, I want to be able to control the LED in an optocoupler to make various sound effects from a synth module (tremolo, phase shifting, vibrato, and such), so I need it to go a lot slower than the 1221Hz that the 20MHz oscillator of the 16F887 is capable of. I'm not opposed to using an external 4MHz oscillator, but 245Hz is still too fast. Ideally, I'd like to get it to go as slow as 3 or 4 seconds to complete a duty cycle. I've been searching previous posts and it sounds like I need to use an interrupt on TMR1, but I have no idea how to do that.
This is what I've got so far. At this point I have to change the code to change the cycle variable. Ideally, I'd use a pot or a button, but I need to get it to be able to go slower than 1221Hz first. Where do I go from here?Code:Dutycycle VAR BYTE Frequency VAR BYTE Frequency=1221 main: For Dutycycle = 255 to 0 Step -1 hpwm 1,Dutycycle,Frequency Next for Dutycycle = 0 to 255 step 1 hpwm 1,Dutycycle,Frequency next GOTO main




Bookmarks