'**************************************************************** '* Name : UNTITLED.BAS * '* Author : Michael Schneider * '* Notice : Copyright (c) 2005 motohoho * '* : All Rights Reserved * '* Date : 9/29/2005 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** DEFINE OSC 4 TRISB = %00000000 'set all of portb to output TRISC = 0 'set all of portc to output mode var byte'this will tell us which mode we are in counterVar var word 'this will provide timing colorGoal var byte[3] 'hold rgb for the color I am going to currentColor var byte[3] 'holds rgb for where I am colorCheck var byte 'will see if I reached my goal x var byte 'for for maxCount con 1' this is how fast it will happen (bigger = slower) clear high portc.0 pause 2000 low portc.0 main: if countervar > maxcount then 'if we counted up above max count then countervar = 0 'reset counter colorcheck = 0 'initialize test variable for x = 0 to 3 if currentcolor[x] = colorgoal[x] then 'check to see if we have colorcheck = colorcheck + 1 'reached our goal on each endif 'if we have add 1 to colorcheck next if colorcheck = 3 then 'if they all matched colorcheck should be 3 mode = mode + 1 'go to the next mode else 'if they didn't all match adjust currentcolor towards goal for x = 0 to 3 'one at a time if currentcolor[x] < colorgoal[x] then currentcolor[x] = currentcolor[x] + 1 else currentcolor[x] = currentcolor[x] - 1 endif next endif else counterVar = countervar + 1 endif select case mode//3 'assign color values according to which mode case 0 'mode//(mod)3 will give us 0, 1 , 2 colorgoal[0] = 25 colorgoal[1] = 200 colorgoal[2] = 0 case 1 colorgoal[0] = 0 colorgoal[1] = 250 colorgoal[2] = 77 case 2 colorgoal[0] = 250 colorgoal[1] = 0 colorgoal[2] = 100 end select pwm portc.0, currentcolor[0], 1 'pwm out colors pwm portc.1, currentcolor[1], 1 pwm portc.2, currentcolor[2], 1 goto main