be80be
Well-Known Member
I want to increase duty with switch1 one step at a time till it gets to 10
And also decrease the duty with switch2 till it's back to 0 but
thanks for any help
And also decrease the duty with switch2 till it's back to 0 but
Code:
Device = 18F1220
Clock = 8
Config OSC = INTIO2
Include "INTOSC8.bas"
Include "PWM0.bas" // import PWM module...
Include "Utils.bas"
Dim Duty As Word // local duty variable...
Dim sw0 as PORTA.0
Dim sw1 as PORTA.1
input (sw0)
input (sw1)
// main program...
If PWM.SetFreq(5000) Then
While true
Duty = 0
Repeat
PWM.SetDutyPercent(Duty)
Inc(Duty) // [COLOR="Red"]Here increase duty with switch1[/COLOR]
DelayMS(100)
Until Duty > 10
Repeat
PWM.SetDutyPercent(Duty)
Dec(Duty) //[COLOR="Red"]decrease the duty with switch2[/COLOR]
DelayMS(100)
Until Duty = 0
Wend
EndIf