#Phidget Analog The PhidgetAnalog library makes for intuitive and lightning fast development without any compromise. For a quick start into your Analog Output project see this Basic PhidgetAnalog Example, and see this Analog Primer Guide to get the most out of your Phidget!
##Methods
Method call | Parameters | Description |
---|---|---|
connect | phidget.params object | Connects the PhidgetAnalog |
quit | N/A | This method requests a disconnect from the Phidget device. The disconnected event will be dispatched when the connection has been successfully disconnected. |
whenReady | function | This executes a function when the Phidget Analog is ready to be used. If you set intervals on this event, you MUST clear them on the detach event! Otherwise, you could set multiple instances of the same interval if a Phidget is detached and re attached |
observe | change handler function | Used for asynchronously observing changes to the Phidget Analog. |
##Data
Key | Data Type | Writable | Description |
---|---|---|---|
type | string | no | 'PhidgetAnalog' |
voltageMaxLimit | number | no | Global upper voltage in Volts |
voltageMinLimit | number | no | Global lower voltage in Volts |
numberOfOutputs | number | no | Number of Voltage Sources |
enabled | array | yes | Power state of Voltage Sources: 1 = on, 0 = off |
voltage | array | yes | Output of each Voltage Source in Volts |
##Getting Started
Initializing PhidgetAnalog devices can be very easy. here is a basic exmple to help get you started
var Phidget = require('../phidgetapi.js').Analog;
var analog=new Phidget();
analog.connect();
analog.whenReady(init)
analog.observeVoltage(voltage);
function init(){
setInterval(
function(){
if(analog.voltage[0] === 0){
analog.voltage[0] = 5;
}else{
analog.voltage[0] = 0;
}
if(analog.enabled === 0){
analog.enabled = 1;
}else{
analog.enabled = 0;
}
},
5000
);
}
function voltage(changes){
console.log(analog.voltage);
}