예제 #1
0
        static Int32 tsPort = 80; // Port Number for ThingSpeak

        #endregion Fields

        #region Methods

        public static void Main()
        {
            AnalogInput A0 = new AnalogInput(Pins.GPIO_PIN_A1);
            A0.SetRange(0, 9999); // Set up analogue range
            button.OnInterrupt += new NativeEventHandler(button_OnInterrupt);
            while (true)
            {
                delayLoop(updateInterval);
                // Check analog input on Pin A0
                 analogReading = A0.Read();
                    updateThingSpeak("field1=" + analogReading.ToString());
            }
        }
예제 #2
0
        public static void Main()
        {
            // write your code here
            PWM led = new PWM(Pins.GPIO_PIN_D5);
            AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);
            pot.SetRange(0, 100);
            int potValue = 0;

            while (true)
            {
                potValue = pot.Read();
                led.SetDutyCycle((unit)potValue);
            }
        }
예제 #3
0
파일: Devices.cs 프로젝트: gflerm/DazCAM
 public Devices(Cpu.Pin jogXPin, Cpu.Pin jogYPin, Cpu.Pin jogZPin)
 {
     if (jogXPin != Cpu.Pin.GPIO_NONE)
     {
         JogXPort = new AnalogInput(jogXPin);
         JogXPort.SetRange(-50, 50);
     }
     if (jogYPin != Cpu.Pin.GPIO_NONE)
     {
         JogYPort = new AnalogInput(jogYPin);
         JogYPort.SetRange(-50, 50);
     }
     if (jogZPin != Cpu.Pin.GPIO_NONE)
     {
         JogZPort = new AnalogInput(jogZPin);
         JogZPort.SetRange(-50, 50);
     }
 }
예제 #4
0
        public static void Main()
        {
            // Create servo object
            PWM servo = new PWM(Pins.GPIO_PIN_D9);

            // Create an input variable that represents the potentiometer
            AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);
            // Set range to fit the pulse width range for position
            pot.SetRange(750, 2250);

            while (true)
            {
                // Update position reading
                int position = pot.Read();
                // Set position based on reading
                servo.SetPulse(20000, (uint)position);

                // Wait to get to the position
                Thread.Sleep(25);
            }
        }
예제 #5
0
 /// <summary>
 /// Expects two analog pins connected to the x & y axis of the joystick.
 /// </summary>
 /// <param name="xAxisPin">Analog pin for the x axis</param>
 /// <param name="yAxisPin">Analog pin for the y axis</param>
 /// <param name="minRange"></param>
 /// <param name="maxRange"></param>
 /// <param name="centerDeadZoneRadius"></param>
 public AnalogJoystick(Cpu.Pin xAxisPin, Cpu.Pin yAxisPin, int minXRange = 0, int maxXRange = 1023, int minYRange = 0, int maxYRange = 1023, int centerDeadZoneRadius = 25) {
     Xinput = new AnalogInput(xAxisPin);
     Xinput.SetRange(minXRange, maxXRange);
     Yinput = new AnalogInput(yAxisPin);
     Yinput.SetRange(minYRange, maxYRange);
     _xRangeFlipped = (minXRange > maxXRange) ? true : false;
     _yRangeFlipped = (minYRange > maxYRange) ? true : false;
     AutoCalibrateCenter(centerDeadZoneRadius);
 }
 public Temt6000LightSensor(Cpu.Pin pin)
 {
     _analogInput = new AnalogInput(pin);
     _analogInput.SetRange(0, 100);
 }