2014-12-04 10:39:10 +00:00
|
|
|
/*
|
|
|
|
* Author: Sarah Knepper <sarah.knepper@intel.com>
|
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* This program and the accompanying materials are made available under the
|
|
|
|
* terms of the The MIT License which is available at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
2014-12-04 10:39:10 +00:00
|
|
|
*
|
2019-07-30 19:41:32 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-12-04 10:39:10 +00:00
|
|
|
*/
|
|
|
|
|
2016-09-09 17:26:58 -07:00
|
|
|
// Load light module
|
|
|
|
var sensor = require('jsupm_light');
|
2014-12-04 10:39:10 +00:00
|
|
|
|
|
|
|
// Create the light sensor object using AIO pin 0
|
2016-09-09 17:26:58 -07:00
|
|
|
var light = new sensor.Light(0);
|
2014-12-04 10:39:10 +00:00
|
|
|
|
2017-03-17 16:18:40 -06:00
|
|
|
// Read the input and print both the normalized ADC value and a rough
|
|
|
|
// lux value, waiting one second between readings
|
2014-12-04 10:39:10 +00:00
|
|
|
function readLightSensorValue() {
|
2017-03-17 16:18:40 -06:00
|
|
|
console.log(light.name() + " normalized value is " + light.getNormalized() +
|
2014-12-04 10:39:10 +00:00
|
|
|
", which is roughly " + light.value() + " lux");
|
|
|
|
}
|
|
|
|
setInterval(readLightSensorValue, 1000);
|