yes yours would still blink, because your controlling the primary fet's on off state with individual I/O's, and controlling a single secondary fet that just controls brightness for all blinking leds. say you set the brightness to 50%, then every led that blinks will be at 50% of its brightness, and you can change the brightness even in the middle of a blink.
Heres a basic, very basic program to do similar
this blinks the leds randomly 50% of the time, and you can randomize the brightness too.
Code:'* Date : 1/26/2013 * '* Version : 1.0 * '* Notes : 12F683 Christmas Light Sample * '* : * '**************************************************************** DEFINE ADC_BITS 10 ' A/D number of bits DEFINE ADC_CLOCK 1 ' Use A/D internal RC clock DEFINE ADC_SAMPLEUS 50 ' Set sampling time in us RES1 Var Word ' A/D converter result RND1 VAR WORD ' Random Result for Light #1 RND2 VAR WORD ' Random Result for Light #2 RND3 VAR WORD ' Random Result for Light #3 TRISIO.0 = 1 ' AN0 is input for Setting Brightness TRISIO.2 = 0 ' PWM1 is output for Dimming FET TRISIO.1 = 0 ' LED1 FET TRISIO.4 = 0 ' LED2 FET TRISIO.5 = 0 ' LED3 FET AGAIN: ADCIN 0, Res1 ' Read Channel 0 data 'Optional replace ACDIN with (RANDOM RES1) res1 = res1 / 256 HPWM 1, res1, 1000 ' Outputs a PWM @ 1khz w/ 256 Steps 'Insert Code for turning LED's on or off here RAndom RND1 Random rnd2 Random rnd3 if rnd1 > 32000 then GPIO.1 = 1 else GPIO.1 = 0 endif if rnd1 > 32000 then GPIO.4 = 1 else GPIO.4 = 0 endif if rnd1 > 32000 then GPIO.5 = 1 else GPIO.5 = 0 endif pause 100 goto again end




Bookmarks