Maxbotix Lv-EZ Sensor With Cylonjs and Edison Arduino Breakout Board
by helloerror in Circuits > Sensors
769 Views, 4 Favorites, 0 Comments
Maxbotix Lv-EZ Sensor With Cylonjs and Edison Arduino Breakout Board
This instructable is for users who wish to interface the LV Ez series Maxbotix sensors to the Edison with arduino breakout board, with cylonjs or johhny-five.
Things You Will Need.
1) Edison with arduino breakout board.
2) Grove base shield.
3) Any LV-Max EZ series sensor.
Solder the Correct Pins
We will use the analog output pin along-with with the obvious VCC/Ground.
Solder the VCC/ground to appropriate pins of the JST connector as shown.
The tricky part is that the grove base shield is a 4 pin board and we need only 3 pins here.
Solder the analog pin output (AN) to the 4th pin of the connector, NOT 3rd.
At this stage, we are good to go. Power up the edison and connect the sensor to any of the pins A0-A3.
Program Using Cylonjs
Use the following code to get the sensor readings. The code provided by the cylonjs website needs to be changed in one line as indicated by my program.
Also, keeping the ranging frequency to 1s is optimal. 0.5s also works but the errors increase slightly. Below 0.5s, the readings are increasingly erratic
Downloads
Code
var Cylon = require('cylon');
Cylon.robot({ connections: { edison: { adaptor: 'intel-iot' } }, devices: { maxbotix: { driver: 'maxbotix', pin: 1 } // connect sensor to pin A1 }, work: function(my) { every((1).seconds(), function() { my.maxbotix.range(function(err,data) { // in website, it shows just function(data) and says range: data, however this is WRONG and one needs to change it to the above. Only then, the data is valid distance measured. console.log("range: " + data + " error: " + err); }); }); } }).start();