{{ CameraColorSampler.spin This program determines the color of an object that is placed about 8cm in front of the camera. It takes 10 samples and returns the RGB values corresponding to the color appearing in a small window near the center of the camera image. This cam then be used for tracking. }} CON _clkmode = xtal1 + pll16x ' This is required for proper timing _xinfreq = 5_000_000 ' This is required for proper timing OBJ CMUCam: "CMUCam" RBC: "RBC" Beeper: "Beeper" VAR word R, G, B PUB Main Beeper.Startup RBC.Init ' Set up bluetooth and wait for Play button to be pressed on PC CMUCam.Start RBC.DebugStrCr(string("Place Object about 5cm in front of the camera ...")) CMUCam.SetConstrainedWindow(35, 64, 45, 80) 'Wait about 2 seconds waitcnt(cnt + 200_000_000) repeat Beeper.Beep(4, 300) CMUCam.ReadColor R := CMUCam.GetRed G := CMUCam.GetGreen B := CMUCam.GetBlue RBC.DebugStr(string("Color value of object: (R,G,B) = ")) RBC.DebugLong(R) RBC.DebugChar(",") RBC.DebugLong(G) RBC.DebugChar(",") RBC.DebugLong(B) RBC.DebugCr 'Send the colour that is being tracked to the PC RBC.SendTrackedColorToPc(R,G,B) CMUCam.SetTrackColor(R,G,B, 30) CMUCam.TrackColor 'Send the tracked position of the colour to the PC RBC.SendTrackedDataToPc(CMUCam.GetTopLeftX, CMUCam.GetTopLeftY, CMUCam.GetBottomRightX, CMUCam.GetBottomRightY)