regfile = "m132def.dat"
$crystal = 1000000
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Prescale = 1
config portb=input
Enable Timer1
Dim W As Word
Dim B As Byte
dim a as bit
Start Timer1
Do
Start Adc
goto main
loop
main:
if portb.0=1
if a=0 then
a=1
else
a=0
endif
endif
do
if portb=0 then exit do
loop
if a=1 then goto manual
if a=0 then goto auto
goto main
auto:
W = Getadc(0)
B = W / 4
Pwm1a = B
goto main
manual:
if portb.1=1 then incr b
if portb.2=1 then decr b
pwm1a=b
waitms 100
goto main