Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3. using Microsoft.SPOT;
  4. using Microsoft.SPOT.Hardware;
  5. using SecretLabs.NETMF.Hardware;
  6. using SecretLabs.NETMF.Hardware.Netduino;
  7.  
  8. namespace CIRC_08
  9. {
  10. public class Program
  11. {
  12.  
  13. static OutputPort led = new OutputPort(Pins.GPIO_PIN_D13, false);
  14. static AnalogInput potentiometer = new AnalogInput(Pins.GPIO_PIN_A0);
  15. static int sensorValue = 0;
  16. static uint period = 0;
  17. static uint duration = 0;
  18. static PWM pwm = new PWM(Pins.GPIO_PIN_D5);
  19.  
  20. public static void Main()
  21. {
  22. while (true)
  23. {
  24. sensorValue = potentiometer.Read();
  25. Debug.Print("pot value = " + sensorValue.ToString());
  26.  
  27. period = (uint)sensorValue / 1023;
  28. duration = (1023 - (uint)sensorValue) / 1023;
  29. pwm.SetPulse(period, duration);
  30.  
  31. Debug.Print("period = " + period.ToString() + " - duration = " + duration.ToString());
  32.  
  33. }
  34. }
  35.  
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement