Device = 18F2420
Clock = 8
Include "InternalOscillator.bas"
Include "RandGen.bas"
Include "Utils.bas"
// import PWM module...
Include "PWM2.bas"
const color(6) as byte = (100, 70, 90, 60, 50, 80)
// local duty variable...
Dim Duty As Byte
dim x as word
// main program...
pwm.SetFreq(5000)
pwm.Start1
While true
for x = 0 to 6
Duty = 0
Repeat
pwm.SetDuty1Percent(Duty)
Inc(Duty)
DelayMS(5)
Until Duty > color(x)
Repeat
pwm.SetDuty1Percent(Duty)
Dec(Duty)
DelayMS(10)
Until Duty = 0
next
Wend