So what have you decided to do? That sounded like a rather firm specification, which hasn't really been met here....08M2.... set brightness of each color independently and mix colors. The red led is at the pin c.1, the green led at the pin c.2 and the blue one at the pin c.4.
#rem remote VIVANCO UR 82 setting for SONY code 107 Up = 24 (start) Down = 25 (stop all) Left = 27 (red brightness down) Right = 26 (red brightness up) CH+ = 16 (blue brightness up) CH- = 17 (blue brightness down) VOL+ = 18 (green brightness up) VOL- = 19 (green brightness down) RGB Red LED c.1 RGB Green LED c.2 RGB Blue LED c.4 RGB Common cathode Ground #endrem #no_data main: setfreq m8 goto red red: do if b0 = 24 then pwm c.1,b1,1 pwm c.2,b2,1 pwm c.4,b3,1 endif irin ,c.3,b10 select case b10 case 24 ;start b0 = 24 case 25 ;stop low c.1 low c.2 low c.4 b0 = 0 b1 = 0 b2 = 0 b3 = 0 case 27 b10 = 0 dec b1 if b1 <1 then b1 = 1 endif case 26 b10 = 0 b1 = b1 + 1 MAX 254 case 16 b10 = 0 b3 = b3 + 1 MAX 254 case 17 b10 = 0 dec b3 if b3 <1 then b3 = 1 endif case 18 b10 = 0 b2 = b2 + 1 MAX 254 case 19 b10 = 0 dec b2 if b2 <1 then b2 = 1 endif endselect goto red loop while b0 = 24
#rem remote VIVANCO UR 82 setting for SONY code 107 Up = 24 Down = 25 Left = 27 Right = 26 CH+ = 16 CH- = 17 VOL+ = 18 VOL- = 19 RGB Red LED c.1 RGB Green LED c.2 RGB Blue LED c.4 RGB Common cathode Ground #endrem #no_data setfreq m8 do if b0 = 24 then pulsout c.1,w1 pulsout c.2,w2 pulsout c.4,w3 endif irin ,c.3,b10 select case b10 ;start RGB case 24 b0 = 24 case 25 ;stop RGB pulsout c.1,0 pulsout c.2,0 pulsout c.4,0 b0 = 0 w1 = 0 w2 = 0 w3 = 0 case 27 ;red down b10 = 0 ;this section if -- endif prevents erratic behaviour ;of the program - variable overflow when pressing ;the button 24 and immediately the button 27 ;used also for the button 17 and 19 w1 = w1 - 10 MIN 10 if w1>1000 then w1=0 endif case 26 ;red up b10 = 0 w1 = w1 + 10 MAX 800 case 16 ;blue up b10 = 0 w3 = w3 + 10 MAX 800 case 17 ;blue down b10 = 0 w3 = w3 - 10 MIN 10 if w3>1000 then w3=0 endif case 18 ;green up b10 = 0 w2 = w2 + 10 MAX 800 case 19 ;green down b10 = 0 w2 = w2 - 10 MIN 10 if w2>1000 then w2=0 endif endselect loop
'program to test RGB LEDs #picaxe 14M2 Setfreq M8 symbol infracnt = b3 'IR variable symbol RedLevel = b4 symbol GreenLevel = b5 symbol BlueLevel = b6 symbol MaxLevelRed = b8 'Set maximum brightness level for Red Led symbol MaxLevelGreen = b9 'Set maximum brightness level for Green Led symbol MaxLevelBlue = b10 'Set maximum brightness level for Blue Led pwmout b.2,150,0 pwmout b.4,150,0 pwmout c.0,150,0 MaxLevelRed= 100 MaxLevelGreen= 100 MaxLevelBlue = 100 do irin c.4,infracnt ' get input from IR receiver select case infracnt case 1 RedLevel = redLevel + 1 pwmduty b.2,redLevel if RedLevel > MaxLevelRed then redlevel = 0 endif case 2 RedLevel = redLevel - 1 pwmduty b.2,redLevel if RedLevel < 0 then redlevel = MaxLevelRed endif case 4 GreenLevel = GreenLevel + 1 pwmduty b.4,GreenLevel if GreenLevel > MaxLevelGreen then GreenLevel = 0 endif case 5 GreenLevel = GreenLevel - 1 pwmduty b.4,GreenLevel if GreenLevel < 0 then GreenLevel = MaxLevelGreen endif case 7 BlueLevel = BlueLevel + 1 pwmduty c.0,BlueLevel if BlueLevel > MaxLevelBlue then BlueLevel = 0 endif case 8 BlueLevel = BlueLevel - 1 pwmduty c.0,BlueLevel if BlueLevel < 0 then BlueLevel = MaxLevelBlue endif case 9 redLevel = 0 GreenLevel = 0 BlueLevel = 0 pwmduty b.4,redLevel pwmduty b.2, GreenLevel pwmduty c.0,BlueLevel end select loop