peony3000

Gadgeteer_DD01_Led_Increment_01

Feb 11th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Threading;
  4. using Microsoft.SPOT;
  5. using Microsoft.SPOT.Presentation;
  6. using Microsoft.SPOT.Presentation.Controls;
  7. using Microsoft.SPOT.Presentation.Media;
  8. using Microsoft.SPOT.Touch;
  9.  
  10. using Gadgeteer.Networking;
  11. using GT = Gadgeteer;
  12. using GTM = Gadgeteer.Modules;
  13. using Gadgeteer.Modules.GHIElectronics;
  14.  
  15. namespace Gadgeteer_DD01_Led_Increment_01
  16. {
  17.     public partial class Program
  18.     {
  19.         // variables that are visible "Program" wide go here
  20.  
  21.         // create a timer robot that ticks every 1000 milliseconds
  22.         GT.Timer timer = new GT.Timer(10000);
  23.  
  24.         // This method is run when the mainboard is powered up or reset.  
  25.         void ProgramStarted()
  26.         {
  27.             /*******************************************************************************************
  28.             Modules added in the Program.gadgeteer designer view are used by typing
  29.             their name followed by a period, e.g.  button.  or  camera.
  30.            
  31.             Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
  32.                 button.ButtonPressed +=<tab><tab>
  33.            
  34.             If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
  35.                 GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
  36.                 timer.Tick +=<tab><tab>
  37.                 timer.Start();
  38.             *******************************************************************************************/
  39.  
  40.             //  create a timer event handler robot that notices when the timer has ticked
  41.             timer.Tick += new GT.Timer.TickEventHandler(timer_Tick);
  42.  
  43.             // start the timer robot running
  44.             timer.Start();
  45.  
  46.             // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
  47.             Debug.Print("Program Started");
  48.         }
  49.  
  50.         void timer_Tick(GT.Timer timer)
  51.         {
  52.             // The incremental count will increase from 0 to 255 in steps of 1
  53.             for (int incrementCount = 0; incrementCount <= 255; incrementCount++)
  54.             {
  55.                 // use the count to set the color
  56.                 multicolorLed.SetRedIntensity(incrementCount);
  57.                 multicolorLed.SetGreenIntensity(incrementCount);
  58.                 multicolorLed.SetBlueIntensity(incrementCount);
  59.             }
  60.         }
  61.     }
  62. }
  63.  
  64. // alternatives
  65.  
  66. // change the increment step size
  67. //incrementCount+=10
  68. // make a method from the color setting
Advertisement
Add Comment
Please, Sign In to add comment