Пример #1
0
        public static void Main()
        {
            //
            //  Create a TSL2561 object operating in interrupt mode.
            //
            TSL2561 tsl2561 = new TSL2561();

            //
            //  Set up the sensor.
            //
            Debug.Print("TSL2561 Interrupt Application.");
            Debug.Print("Device ID: " + tsl2561.ID);
            tsl2561.TurnOff();
            tsl2561.SensorGain = TSL2561.Gain.High;
            tsl2561.Timing     = TSL2561.IntegrationTiming.Ms402;
            tsl2561.TurnOn();
            tsl2561.LightLevelChanged += (s, e) =>
            {
                Debug.Print("Light intensity: " + e.CurrentValue.ToString("f2"));
            };
            //
            //  Put the application to sleep as the interrupt handler will deal
            //  with any changes in sensor data.
            //
            Thread.Sleep(Timeout.Infinite);
        }
Пример #2
0
        public static void Main()
        {
            TSL2561 tsl2561 = new TSL2561();

            Debug.Print("Polled TSL2561 Application.");
            Debug.Print("Device ID: " + tsl2561.ID);
            tsl2561.TurnOff();
            tsl2561.SensorGain = TSL2561.Gain.High;
            tsl2561.Timing     = TSL2561.IntegrationTiming.Ms402;
            tsl2561.TurnOn();
            //
            //  Repeatedly read the light intensity.
            //
            while (true)
            {
                var adcData = tsl2561.SensorReading;
                Debug.Print("Data0: " + adcData[0] + ", Data1: " + adcData[1]);
                Debug.Print("Light intensity: " + tsl2561.Luminosity.ToString("f2"));
                Thread.Sleep(2000);
            }
        }