Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- using Microsoft.SPOT;
- using Microsoft.SPOT.Hardware;
- using SecretLabs.NETMF.Hardware;
- using SecretLabs.NETMF.Hardware.Netduino;
- namespace CIRC_08
- {
- public class Program
- {
- static OutputPort led = new OutputPort(Pins.GPIO_PIN_D13, false);
- static AnalogInput potentiometer = new AnalogInput(Pins.GPIO_PIN_A0);
- static int sensorValue = 0;
- static uint period = 0;
- static uint duration = 0;
- static PWM pwm = new PWM(Pins.GPIO_PIN_D5);
- public static void Main()
- {
- while (true)
- {
- sensorValue = potentiometer.Read();
- Debug.Print("pot value = " + sensorValue.ToString());
- period = (uint)sensorValue / 1023;
- duration = (1023 - (uint)sensorValue) / 1023;
- pwm.SetPulse(period, duration);
- Debug.Print("period = " + period.ToString() + " - duration = " + duration.ToString());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement