upm/examples/javascript/tcs3414cs.js
Mihai Tudor Panu 89d5de43e0 license: update to SPDX style license text throughout
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
2020-03-05 15:13:36 -08:00

32 lines
785 B
JavaScript

/*
* Author: Zion Orent <zorent@ics.com>
* Copyright (c) 2014 Intel Corporation.
*
* 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.
*
* SPDX-License-Identifier: MIT
*/
var colorSensor = require('jsupm_tcs3414cs');
// Instantiate the color sensor on I2C
var mycolorSensor = new colorSensor.TCS3414CS();
var rgb = new colorSensor.tcs3414sc_rgb_t;
// Print out the r, g, b, and clr value every 0.5 seconds
setInterval(function()
{
mycolorSensor.readRGB(rgb);
console.log(rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + rgb.clr);
}, 500);
// Print message when exiting
process.on('SIGINT', function()
{
console.log("Exiting...");
process.exit(0);
});