Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 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 PWM pwm = new PWM(Pins.GPIO_PIN_D5);
  16.  
  17. public static void Main()
  18. {
  19. int sensorValue = 0;
  20. uint period = 10000;
  21. uint duration = 0;
  22.  
  23. while (true)
  24. {
  25. sensorValue = potentiometer.Read();
  26. Debug.Print("pot value = " + sensorValue.ToString());
  27. duration = (1023 - (uint)sensorValue) / 1023;
  28. pwm.SetPulse(period, duration);
  29.  
  30. Debug.Print("duration = " + duration.ToString());
  31.  
  32. }
  33. }
  34.  
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement