Exemplo n.º 1
0
        private static void DemoMux2()
        {
            // In this demo, one sensor is on the I2CMux Click (which is on Quail's socket #1) on channel 0 and the other sensor on Quail's socket #2
            _mux = new I2CMuxClick(Hardware.SocketOne, 0xE0 >> 1, 100000);

            var _prox1 = new ProximityClick(Hardware.SocketOne);
            var _prox2 = new ProximityClick(Hardware.SocketTwo);

            // Activate reading for the first sensor
            _mux.ActiveChannels = 0b00000001;
            Debug.WriteLine($"Proximity Click on socket #1 reads a distance of {_prox1.Distance()} m");

            // Deactivate all channels on the I2CMux Click so that the command will not be listened
            // This will allow the I2C command to be directed to the sensor on socket #2
            _mux.ActiveChannels = 0b00000000;
            Debug.WriteLine($"Proximity Click on socket #2 reads a distance of {_prox2.Distance()} m");
        }
Exemplo n.º 2
0
        public static void Main()
        {
            _prox = new ProximityClick(Hardware.SocketTwo);                   // Proximity at address 0x70 on socket 2

            Debug.WriteLine("Chip revision : " + _prox.ChipRevision);         // Get chip version and firmware revision

            // Set IR Led current to 200 mA  (20 x 10).
            // Warning : different values of current will cause different readings for the same distance (see datasheet).
            _prox.IRLedCurrent  = 20;
            _prox.ProximityRate = 1;                                    // Set Proximity rate measurement to 3.9 measures/s

            Debug.WriteLine("Ambient light : " + _prox.AmbientLight()); // Get ambient light value

            while (true)
            {
                Debug.WriteLine("Proximity : " + _prox.Distance());               // Get proximity value
                Thread.Sleep(100);
            }
        }