protected void InitRobot()
        {

            if (gpio == null) { return; }

            leftMotor = new Motor(23, 22);
            rightMotor = new Motor(24, 25);

            distanceSensors = new IDistance[] {
                new UltraSound(26, 20, "right", 50),
                new UltraSound(12, 5, "left", 50),
                new UltraSound(13, 6, "center", 50),
           //     new InfraRed(18, "centerIR", 10)
            };
        }
 public Motor Motor(MotorId motor) {
     switch (motor) {
         case MotorId.MotorOne:
             if (motors[0] == null) { motors[0] = new Motor((int)MotorMap.OnePlus, (int)MotorMap.OneMinus); }
             return motors[0];
         case MotorId.MotorTwo:
             if (motors[1] == null) { motors[1] = new Motor((int)MotorMap.TwoPlus, (int)MotorMap.TwoMinus); }
             return motors[1];
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();


            // How to use the ADS1015 and MCP3002 ADC/Converters

            AdcProviderManager adcManager = new AdcProviderManager();

            adcManager.Providers.Add(new ADS1015(ADS1015.Gain.Volt33));     // Load up ADS1015 4 Channel ADC Converter
            adcManager.Providers.Add(new MCP3002());                       // Load up MCP3002 2 Channel ADC Converter

            IReadOnlyList<AdcController> adcControllers = await adcManager.GetControllersAsync();  // load ADCs


            //use the ADCs create above
            Ldr light = new Ldr(adcControllers[0].OpenChannel(0)); // create new light sensor using the ADS1015 ADC provider
            MCP9700A temp = new MCP9700A(adcControllers[1].OpenChannel(0)); // create temperature sensor using MCP3002 ADC Provider

            var lightLevel = light.ReadValue;        // read light level from the first ADC ADS1015
            var lightRatio = light.ReadRatio;

            var celsius = temp.Temperature.DegreesCelsius;  // read temp in celsius
            var fahrenheit = temp.Temperature.DegreesFahrenheit;  // read temp in celsius


            BMP280 tempAndPressure = new BMP280();

            var degreesCelsius = tempAndPressure.Temperature.DegreesCelsius;  // read temp in celsius - plenty of other units
            var degreesFahrenheit = tempAndPressure.Temperature.DegreesFahrenheit;

            var bars = tempAndPressure.Pressure.Bars;       // read air pressure in bars - plenty of other units
            var hectopascals = tempAndPressure.Pressure.Hectopascals;  // read air pressure in Hectopascals
            var Atmospheres = tempAndPressure.Pressure.Atmospheres;


            // LED demo

            Led led = new Led(4);  // open led on pin 4
            led.On();  // turn on
            await Task.Delay(1000);  // wait for 1 second
            led.Off(); // turn off

            // relay Demo
            Relay relay = new Relay(6);
            relay.On(); // turn relay on
            await Task.Delay(1000);  // wait for 1 second
            led.Off(); // turn relay off


            // motor demo
            Motor leftMotor = new Motor(22, 24);
            Motor rightMotor = new Motor(12, 25);

            //now do a tight circle
            leftMotor.Forward();
            rightMotor.Backward();
            await Task.Delay(5000);  // wait for 5 second
            leftMotor.Stop();
            rightMotor.Stop();
        }