PWM chaser using pic16f877 help!

General discussion on mikroBasic.
Post Reply
Author
Message
kenshin8878
Posts: 20
Joined: 20 Jun 2007 09:45

PWM chaser using pic16f877 help!

#1 Post by kenshin8878 » 30 Nov 2010 04:42

guys can you help me if you have sample program regarding on my topic...i have a running LED fade project...pls help me

thanks

bluumax
Posts: 32
Joined: 20 Jan 2008 09:50

Re: PWM chaser using pic16f877 help!

#2 Post by bluumax » 26 Jul 2015 07:04

Just in case anyone comes across this looking for an example.
Fade up, fade down

Code: Select all

 Sub procedure Fade
   Fade_Up = 1
   While Fade_Up < 40
      Fade_Loop = 0
      While Fade_Loop < 3
      PortB = 0
      i = 40 - Fade_Up    ' Off Loop
         While i > 0
            delay_us(350)
            Dec (i)
         Wend
      PortB = 0xFF
      i = Fade_Up       ' On Loop
         While i > 0
            delay_us(350)
            Dec (i)
         Wend
      Inc (Fade_Loop)
      Wend             ' do this 3 times
   Inc (Fade_Up)        ' do this 40 times
   Wend                ' total 120 times 20ms
'---------------------------------------------
delay_ms(1000)
'---------------------------------------------
   Fade_Dn = 1
   While Fade_Dn < 40
      Fade_Loop = 0        ' Each Loop is 20 ms (40* 500uS)
      While Fade_Loop < 3
      PortB = 0xFF
      i = 40 - Fade_Dn    ' Off Loop
         While i > 0
            delay_us(150)
            Dec (i)
         Wend
      PortB = 0
      i = Fade_Dn       ' On Loop
         While i > 0
            delay_us(300)
            Dec (i)
         Wend
      Inc (Fade_Loop)
      Wend             ' do this 3 times
   Inc (Fade_Dn)        ' do this 40 times
   Wend                ' total 120 times 20ms
   delay_ms(500)
  RETURN
 end sub

Post Reply

Return to “mikroBasic General”