unkwntech

PWM.DutyCycle

Apr 9th, 2012
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System.Threading;
  2. using Microsoft.SPOT;
  3. using Microsoft.SPOT.Hardware;
  4.  
  5. namespace ShieldBase_PWMTest
  6. {
  7.     public class Program
  8.     {
  9.         public static void Main()
  10.         {
  11.             PWM led = new PWM(Cpu.PWMChannel.PWM_3, 1000, 0.5, false);
  12.             led.Start();
  13.             for (int i = 0; i < 100; i++)
  14.             {
  15.                 Debug.Print(i.ToString());
  16.                 led.Stop();
  17.                 led.DutyCycle = i; //EXCEPTION
  18.                 led.Start();
  19.                 Thread.Sleep(100);
  20.             }
  21.                
  22.  
  23.         }
  24.     }
  25. }
  26.  
  27. /*
  28. Throws:
  29. An unhandled exception of type 'System.InvalidOperationException' occurred in Microsoft.SPOT.Hardware.PWM.dll
  30. */
Advertisement
Add Comment
Please, Sign In to add comment