Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Presentation;
- using Microsoft.SPOT.Presentation.Controls;
- using Microsoft.SPOT.Presentation.Media;
- using Microsoft.SPOT.Touch;
- using Gadgeteer.Networking;
- using GT = Gadgeteer;
- using GTM = Gadgeteer.Modules;
- using Gadgeteer.Modules.GHIElectronics;
- using Gadgeteer.Modules.Seeed;
- namespace Gadgeteer_DD02_Oled_Colorsense_01
- {
- public partial class Program
- {
- // create a timer that ticks every half second
- GT.Timer timer = new GT.Timer(500);
- // This method is run when the mainboard is powered up or reset.
- void ProgramStarted()
- {
- /*******************************************************************************************
- Modules added in the Program.gadgeteer designer view are used by typing
- their name followed by a period, e.g. button. or camera.
- Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
- button.ButtonPressed +=<tab><tab>
- If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
- GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
- timer.Tick +=<tab><tab>
- timer.Start();
- *******************************************************************************************/
- // create a timer tick event handling robot
- timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
- // start the timer ticking
- timer.Start();
- // turn on the color sensor lights
- colorSense.ToggleOnboardLED(true);
- // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
- Debug.Print("Program Started");
- }
- void timer_Tick(GT.Timer timer)
- {
- // the timer ticked!
- Debug.Print("Red " + colorSense.ReadColorChannels().Red);
- Debug.Print("Green " + colorSense.ReadColorChannels().Green);
- Debug.Print("Blue " + colorSense.ReadColorChannels().Blue);
- Debug.Print("Clear " + colorSense.ReadColorChannels().Clear);
- // match the oled screen color to the color sensor readings
- oledDisplay.SimpleGraphics.BackgroundColor = GT.Color.FromRGB((byte)colorSense.ReadColorChannels().Red, (byte)colorSense.ReadColorChannels().Green, (byte)colorSense.ReadColorChannels().Blue);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment