be80be
Well-Known Member
A simple PWM led dimmer with the 18F1220 here the code you can use it with and 18fxxx just need swordfish basic. And Thanks to 3v0
Now the video not that good it better live hard to film a led
And here the same code but I'm dimming a ac light bulb
Code:
Dim Duty As Word // local duty variable...
Dim sw0 As PORTA.0
Dim sw1 As PORTA.1
Input (sw0)
Input (sw1)
SetAllDigital
// main program...
If PWM.SetFreq(5000) Then
Duty = 0
While true
PWM.SetDutyPercent(Duty)
If ( (sw0 = 1) And (Duty < 10) ) Then
Inc(Duty)
DelayMS(10)
While sw0 = 1 Wend
EndIf
PWM.SetDutyPercent(Duty)
If ( (sw1 = 1) And (Duty >0) ) Then
Dec(Duty)
DelayMS(10)
while sw1 = 1 wend
EndIf
Wend
EndIf
Now the video not that good it better live hard to film a led
And here the same code but I'm dimming a ac light bulb
Last edited by a moderator: