Sunday, 9 April 2017

Cylon.js digitalRead() with Beaglebone black

I am using Beaglebone Black with Nodejs version 4.8.0 with Debian 8.7.

I was trying to run digitalRead() on my input PIR Motion Sensor, but whenever I try to do that my output is always underfined which is from variable value

I had check with my PIR motion Sensor with multimeter there is voltage output, I just need to read it from that pin. I am not familiar with this new syntax this is the first time I get in touch with Cylon.js. Is there any step I did it wrong ? Or cylon.js do not actually support for driver PIR Motion Sensor ?

var Cylon = require('cylon');

// Initialize the robot
Cylon.robot({
  connections: {
    beaglebone: { adaptor: 'beaglebone' }
  },

  devices: {
    led: { driver: 'direct-pin', pin: 'P8_13' },
    pin: { driver: 'direct-pin', pin: 'P8_19' }
  },

  work: function(my) {
    var value = 0;
    every((1).second(), function() {
        val = my.digitalRead('P8_19');
        console.log(val);
        if(value == 1){
            my.led.digitalWrite(1);
            console.log('ON');
        }else{
            my.led.digitalWrite(0);
            console.log('off');
        }
    });
    }

}).start();

P.S: Oh ya I use direct pin for led, because I also wanna output digitalWrite to it. Hope it clarify it. and pin is my PIR Motion Sensor.



via Trelyon Lim

No comments:

Post a Comment