Digital components can fit in Boolean data type. Floating point data type is correct to describe analog values. BoneScript provides the function analogRead()
to read the voltage at the analog pin. These pins are input-only. So, there is no need to initialize them using pinMode()
. Here is the prototype of the analogRead()
function:
analogRead(pin, callback)
The parameters of this function are described as follows:
pin
: BeagleBone pin identifier stringcallback
: Name of function that will be called automatically whenanalogRead()
finishes.
The first parameter pin
is used to find the corresponding sysfs file to read data from. Similar to the digitalRead()
function, the analogRead()
function is blocking. It waits till analog voltage is read and the ADC conversion is done. The Node execution engine freezes till this happens. So, there is need for an asynchronous callback function. The second parameter is the callback function, which will be called automatically when...