Here is what I have so far, as you can see this project will later include some servos but they are unused at this time.
The error that I get is on the line where I set the duty cycle. “pwm.SetDutyCycle(irValue);” the error is Cannot convert int to uint. I tried making my variable “irValue” a uint but then it has trouble reading the analog pin.
Is there a convert or case that I can use? For instance there is a ToString function that works but not something that can convert an int to a uint. Can I even use the DutyCycle like I am wanting to? I have found some very confusing Netduino PWM articles and not one of them use PWM in the same manner as the other.
Sorry I am a beginner with .net so after hours of searching I decided to call it a day and hopefully someone here can answer this easily.
using System; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; using Servo_API; namespace ServoKnob { public class Program { public static void Main() { Servo servo = new Servo(Pins.GPIO_PIN_D9); AnalogInput irSensor = new AnalogInput(Pins.GPIO_PIN_A0); int irValue; PWM pwm = new PWM(Pins.GPIO_PIN_D10); while (true) { irValue = irSensor.Read(); irValue = irValue / 5; pwm.SetDutyCycle(irValue); // servo.Degree = irValue; Debug.Print(irValue.ToString()); } } } }
Thanks!