How to use the johnny-five.Light function in johnny-five

To help you get started, we’ve selected a few johnny-five examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CommonGarden / Grow-IoT / drivers / Raspberry-Pi / grow-hub.js View on Github external
// Create a new growHub instance and connect to https://growHub.commongarden.org
  var growHub = new GrowInstance({
    uuid: 'bfeffe4c-b78c-4f3f-9c5e-827684ea96da',
    token: 'xsG6G5PyQMKPycWN5AjZvuSD2K4GmMcn',
    component: 'grow-hub',

    // Properties can be updated by the API
    properties: {
      state: null,
      duration: 2000,
      interval: 5000,
      targets: {},
    },

    light: new five.Light({
      controller: 'TSL2561'
    }),

    multi: new five.Multi({
      controller: 'SI7020'
    }),

    start: function () {
      console.log('Grow-Hub initialized.');

      // This must be called prior to any I2C reads or writes.
      // See Johnny-Five docs: http://johnny-five.io
      board.i2cConfig();

      board.i2cRead(0x64, 32, function (bytes) {
        var bytelist = [];
github GabeWeiss / google-sorting-demo / lenovo / simple2.js View on Github external
board.on("ready", function() {
    //  servo = five.Servo({
    // 
    //         pin: 3,
    //         startAt: 100,
    //         range: [0, 180],
    //         interval: 1000
    // });
    //  servo.sweep([0,300]);
    //  left();
    var sensor = false;
    for (var i = 0; i <= 0; i++) {
        sensor = new five.Light("A" + i);
        sensor.on("change", function() {
            sensorValues[this.pin] = this.value;
            console.log(this.value);
        });
    }
    setInterval(function() {
        console.log("----------------");
        Object.keys(sensorValues).forEach(function(key) {
            console.log(key + ":" + sensorValues[key]);
        });
        console.log("----------------");
    }, 1000);
});
var sensorValues = {};
github GabeWeiss / google-sorting-demo / server / server.js View on Github external
Object.keys(sensors).forEach(function(key) {
                var sensor = new five.Light("A" + key);
                if (key == 0) {
                    // As the gear rolls down the ramp, it covers a light sensor underneath where the
                    // gear hits the grabber claw. This is what's used by the demo to know whether
                    // or not it should be dropping a gear or not
                    sensor.on("change", function() {
                        //console.log(this.value);
                        // the Debug below is used to test to be sure the lightThreshold is tuned
                        // correctly
                        if (this.value > lightThreshold) {
                            //if (lightSensorIsBlocked == true) {
                                //console.log("Changing lightSensorIsBlocked value from false to true");
                            //}
                            lightSensorIsBlocked = false;
                        } else {
                            //if (lightSensorIsBlocked == false) {
                                //console.log("Changing lightSensorIsBlocked value from true to false");
github CommonGarden / Grow-IoT / packages / Grow.js / examples / rasp-pi / GrowTent.js View on Github external
board.on('ready', function start() {
    // Declare needed variables.
    var pH_reading, eC_reading, water_temp, emit_data;

    var lux = new five.Light({
        controller: 'TSL2561'
    });

    var multi = new five.Multi({
        controller: 'SI7020'
    });

    var growHub = new Grow({
        uuid: '48d7251e-45c2-43b3-84bd-cdac0bd8c412',
        token: '3XMJdsSsTqmxMYjEMzaBtqrGwk7hxozv',
        component: 'GrowHub',

        camera: Cam,

        properties: {
            light_state: null,
github stevekinney / nodebots-workshop / example-code / 05-light-sensor / 02-light-site / index.js View on Github external
board.on('ready', () => {
  const light = new five.Light('a7');

  const express = require('express');
  const bodyParser = require('body-parser');
  const app = express();
  const http = require('http').Server(app);
  const io = require('socket.io')(http);
  const port = process.env.PORT || 80;

  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded());
  app.use(bodyParser.urlencoded({ extended: true }));

  app.use(express.static(path.join(__dirname, 'public')));

  app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, '/public/index.html'));

johnny-five

The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis