$regfile = "m16def.dat" : $crystal = 1000000
Config Lcdpin = Pin , Db7 = Pinc.5 , Db6 = Pinc.4 , Db5 = Pinc.3 , Db4 = Pinc.2 , E = Pinc.1 , Rs = Pinc.0
Config Lcd = 16 * 2 : Cursor Off : Cls
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 64
Config Timer2 = Pwm , Compare Pwm = Clear Down , Prescale = 64
Start Timer1 : Start Timer2
Ddrd = 255 : Ddrb = 0 : Portb = 255
Dim R As Byte , G As Byte , B As Byte
'===============================================================================
Do
Debounce Pinb.0 , 0 , Incr_r , Gosub
Debounce Pinb.1 , 0 , Decr_r , Gosub
Debounce Pinb.2 , 0 , Incr_g , Gosub
Debounce Pinb.3 , 0 , Decr_g , Gosub
Debounce Pinb.4 , 0 , Incr_b , Gosub
Debounce Pinb.5 , 0 , Decr_b , Gosub
Loop
'===============================================================================
Incr_r:
If R <> 255 Then Incr R
Pwm1a = R
Home : Lcd "R=" ; R ; " "
Return
Decr_r:
If R <> 0 Then Decr R
Pwm1a = R
Home : Lcd "R=" ; R ; " "
Return
'===============================================================================
Incr_g:
If G <> 255 Then Incr G
Pwm1b = G
Locate 1 , 9 : Lcd "G=" ; G ; " "
Return
Decr_g:
If G <> 0 Then Decr G
Pwm1b = G
Locate 1 , 9 : Lcd "G=" ; G ; " "
Return
'===============================================================================
Incr_b:
If B <> 255 Then Incr B
Compare2 = B
Locate 2 , 1 : Lcd "B=" ; B ; " "
Return
Decr_b:
If B <> 0 Then Decr B
Compare2 = B
Locate 2 , 1 : Lcd "B=" ; B ; " "
Return
'===============================================================================