コード例 #1
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);
 }
コード例 #2
0
ファイル: AnalogJoystick.cs プロジェクト: josemotta/Netduino
        /// <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 minRange = 0, int maxRange = 1023, int centerDeadZoneRadius = 10)
        {
            MaxRange = maxRange;

            Xinput = new AnalogInput(xAxisPin);
            Xinput.SetRange(minRange, maxRange);

            Yinput = new AnalogInput(yAxisPin);
            Yinput.SetRange(minRange, maxRange);

            AutoCalibrateCenter(centerDeadZoneRadius);
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
        //// changing the blinking speed with potentiomenter
        //public static void Main()
        //{
        //    OutputPort led = new OutputPort(Pins.GPIO_PIN_D0, false);

        //    AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);

        //    int potValue = 0;

        //    pot.SetRange(100, 250);
        //    while (true)
        //    {
        //        potValue = pot.Read();
        //        led.Write(true);

        //        Thread.Sleep(potValue);
        //        led.Write(false);

        //        Thread.Sleep(potValue);
        //    }
        //}

        // Dimming the LED light with potetniometer
        public static void Main()
        {
            PWM led = new PWM(Pins.GPIO_PIN_D5);

            AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);

            int potValue = 0;

            pot.SetRange(0, 100);

            while (true)
            {
                potValue = pot.Read();
                led.SetDutyCycle((uint)potValue);
            }
        }
コード例 #5
0
        public static void Main()
        {
            //
            SecretLabs.NETMF.Hardware.PWM led = new SecretLabs.NETMF.Hardware.PWM(Pins.GPIO_PIN_D5);
            AnalogInput pot = new AnalogInput(Pins.GPIO_PIN_A0);

            pot.SetRange(0, 100);

            int potValue = 0;

            while (true)
            {
                //read potentiometer value
                potValue = pot.Read();

                //change LED intensity based on potentiometer value
                led.SetDutyCycle((uint)potValue);
            }
        }
コード例 #6
0
        public static void Main()
        {
            // Initialize the value.
            int Value = 0;

            // Setup the range.
            Sensor.SetRange(0, Range);

            // Initialization test.
            for (int i = 0; i <= 10; i++)
            {
                LED.Display(i);
                Thread.Sleep(2000);
            }

            // Read, Print, Transmit, Sleep loop.
            while (true)
            {
                Value = Sensor.Read(); // So we only read once.
                Debug.Print("Value to Transmit: " + Value);
                LED.Display(Value);
                Thread.Sleep(TransmissionGap); // Sleep for a short time.
            }
        }