CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 VAR long config_byte long device_address long tempd long PWMCog[100] byte Cog long tempa OBJ 'give the serialdriver object wich is defined in the file "FullDuplexSerial.SPIN" m : "MAX6953" s : "FullDuplexSerialPlus" PUB Main s.start(31, 30, 0, 9600) m.Init(14,15) 'WaitCnt(clkfreq*5+cnt) s.str(string("Initialized")) s.tx(13) m.SetDeviceAddress($00) m.Shutdown(false,true) m.SetIntensityAll($00) '-------------- m.WriteData($05,$80) ' New char addr? m.WriteData($05,%01100001) m.WriteData($05,%01000000) m.WriteData($05,%00000011) m.WriteData($05,%01000000) m.WriteData($05,%01100001) m.WriteData($20,$80) WaitCnt(clkfreq+10+cnt) tempa :=$41 repeat tempa from $41 to $5A m.WriteChar(tempa) WaitCnt(clkfreq/2+cnt) cognew(Flex,@PWMCog) tempa:=$41 repeat tempa from $41 to $5A m.WriteChar(tempa) WaitCnt(clkfreq/2+cnt) m.ShutDown(true,true) PUB Flex tempd:=0 config_byte:=0 repeat config_byte from 0 to 10 repeat tempd from 0 to 10 m.SetIntensityAll(tempd) WaitCnt(clkfreq/15+cnt) repeat tempd from 10 to 0 m.SetIntensityAll(tempd) WaitCnt(clkfreq/15+cnt)