2014-04-22 15:51:28 +01:00
|
|
|
/*
|
2014-08-14 15:16:23 -04:00
|
|
|
* Author: Dan Yocom <dan.yocom@intel.com>
|
2014-04-22 15:51:28 +01:00
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
|
*
|
2019-05-09 09:47:11 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2014-04-22 15:51:28 +01:00
|
|
|
*/
|
|
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
"use strict";
|
2014-04-08 18:43:26 +01:00
|
|
|
|
2017-02-23 00:57:19 -06:00
|
|
|
const mraa = require('mraa'); //require mraa
|
|
|
|
|
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the console
|
|
|
|
|
|
|
|
|
|
let analogPin0 = new mraa.Aio(0); //setup access analog inpuput pin 0
|
|
|
|
|
let analogValue = analogPin0.read(); //read the value of the analog pin
|
|
|
|
|
let analogValueFloat = analogPin0.readFloat(); //read the pin value as a float
|
2014-08-14 15:16:23 -04:00
|
|
|
console.log(analogValue); //write the value of the analog pin to the console
|
2015-02-04 20:09:56 +01:00
|
|
|
console.log(analogValueFloat.toFixed(5)); //write the value in the float format
|