' Simple RGB/CMY fader for PICAXE-08m
' Uses Radio Shack 276-0028 5mm common-anode RGB LED
' Use 3 1.5V batteries for supply
' Hook LED long lead to V+ 
' Hook Other pins to DIP pins 3, 4, and 5 each through a 330 ohm resistor.

symbol green = 1
symbol blue = 2
symbol red = 4

symbol i = b4
symbol aa = b2
symbol bb = b3


main:
	gosub alloff

	aa = red
	gosub rgbramp

	aa = green
	gosub rgbramp
	
	aa = blue
	gosub rgbramp

	aa = blue
	bb = green
	gosub cmyramp

	aa = red
	bb = blue
	gosub cmyramp

	aa = red
	bb = green
	gosub cmyramp

	goto main

rgbramp:
	high red
	high blue
	high green
	for i=255 to 0 step -4
	  pwm aa,i,1
        next i
	for i = 0 to 255 step 4
	  pwm aa,i,1
        next i
        return


cmyramp:
	high red
	high blue
	high green
	for i=255 to 0 step -8
	  pwm aa,i,1
	  pwm bb,i,1
        next i
	for i = 0 to 255 step 8
	  pwm aa,i,1
	  pwm bb,i,1
        next i
        return

rgb:
	high red
	high blue
	high green
	low aa
	pause 500
	return

cmy:
	low red
	low blue
	low green
	high aa
	pause 500
	return


alloff:
	high red
	high blue
	high green
	return
