AthenaHS dim bluecount,redcount,greencount dim curcount,cycle,rnd 'LED Ports const portblue1 0 const portred1 1 const portgreen1 2 const portblue2 3 const portred2 4 const portgreen2 5 const maxcount 150 'Sets up the PWM frequency and resolution setio 0,1,2,3,4,5 'Start Point for lights bluecount = 1 redcount = 150 greencount = 150 loop: gosub Red_Down gosub Blue_Up gosub Green_Down gosub Red_Up gosub Blue_Down gosub Green_Up goto loop '------------------------------------ Blue_Up: '------------------------------------ for bluecount = 1 to maxcount gosub pwm next return '------------------------------------ Blue_Down: '------------------------------------ for bluecount = maxcount to 1 step -1 gosub pwm next return '------------------------------------ Red_Up: '------------------------------------ for redcount = 1 to maxcount gosub pwm next return '------------------------------------ Red_Down: '------------------------------------ for redcount = maxcount to 1 step -1 gosub pwm next return '------------------------------------ Green_Up: '------------------------------------ for greencount = 1 to maxcount gosub pwm next return '------------------------------------ Green_Down: '------------------------------------ for greencount = maxcount to 1 step -1 gosub pwm next return '----------------------------------------- ' Generate the light '----------------------------------------- pwm: random 40,rnd 'This will determine how long we stay with a color rnd = rnd + 5 'With a minimum of 5 counts 'To create the 6 PWM signals we turn all ports on then turn them off ' as each color count is reached. for cycle = 1 to rnd configio 0,1,2,3,4,5 for curcount = 1 to maxcount if curcount = bluecount then gosub offblue endif if curcount = redcount then gosub offred endif if curcount = greencount then gosub offgreen endif next next return 'You may want to place this code directly in the if statements ' The KRcompression technology built into the Athena engine ' is centered around modular code so this particualr way ' is more efficiant than single if statements 'Port Handlers offblue: input portblue2 input portblue1 return offred: input portred1 input portred2 return offgreen: input portgreen1 input portgreen2 return