How to use the johnny-five.Board 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 sayanee / talks / web-sensors / code / minihack / index.js View on Github external
// code and wiring the breadboard
// http://johnny-five.io/examples/potentiometer/

var port = 8000
var five = require('johnny-five')
var board = new five.Board()
var potentiometer
var express = require('express')
var app = express().use(express.static('public'))
var server = app.listen(port, function () {
  console.log('App running on ' + port)
})
var io = require('socket.io').listen(server)

board.on('ready', function() {
  var sockets = []

  potentiometer = new five.Sensor({
    pin: 'A2',
    freq: 1000 // get the sensor value per milliseconds
  })
github ThingLabsIo / IoTLabs / Photon / Lab06 / lab06_light.js View on Github external
protocol: process.env.PROTOCOL || 'https',
    api_key: process.env.API_KEY || 'YOUR API KEY HERE'
};
config.store = new Store(config);
service = new nitrogen.Service(config);

// Create a new Nitrogen device for the photoresistor
// This device will send data it reads from a sensor
indicatorLight = new nitrogen.Device({
    nickname: 'lab06_indicatorLight',
    name: 'Lab 06 Indicator Light',
    tags: ['sends:_intensity', 'executes:_lightLevel']
});

// Define the Johnny Five board as your Particle Photon
board = new five.Board({
  io: new particle({
    token: process.env.PARTICLE_KEY || 'YOUR API KEY HERE',
    deviceId: process.env.PARTICLE_DEVICE || 'YOUR DEVICE ID OR ALIAS HERE'
  })
});

var LEDPIN = "D0";

// Define a command tag that you can scope to.
// This will enable you to filter to only relevant messages
var cmdTag = 'lab06';

// Connect the indicatorLight device defined above
// to the Nitrogen service instance.
service.connect(indicatorLight, function(err, session, indicatorLight) {
    if (err) { return console.log('Failed to connect lab06_indicatorLight: ' + err); }
github ThingLabsIo / IoTLabs / Photon / Weather / weather.js View on Github external
// Create the client instanxe that will manage the connection to your IoT Hub
// The client is created in the context of an Azure IoT device.
var client = Client.fromConnectionString(connectionString, Protocol);
// Extract the Azure IoT Hub device ID from the connection string 
// (this may not be the same as the Photon device ID)
var deviceId = device.ConnectionString.parse(connectionString).DeviceId;
console.log("Device ID: " + deviceId);

// Create a Johnny-Five board instance to represent your Particle Photon
// Board is simply an abstraction of the physical hardware, whether is is a 
// Photon, Arduino, Raspberry Pi or other boards. 
// When creating a Board instance for the Photon you must specify the token and device ID
// for your Photon using the Particle-IO Plugin for Johnny-five.
// Replace the Board instantiation with the following:
var board = new five.Board({
  io: new Particle({
    token: token,
    deviceId: 'YOUR PARTICLE PHOTON DEVICE IS OR ALIAS'
  })
});

// The board.on() executes the anonymous function when the 
// board reports back that it is initialized and ready.
board.on("ready", function() {
    console.log("Board connected...");
    
    // Open the connection to Azure IoT Hub
    // When the connection respondes (either open or error)
    // the anonymous function is executed
    client.open(function(err) {
        console.log("Azure IoT connection open...");
github Azure-Samples / iot-hub-node-intel-edison-getstartedkit / remote_monitoring / remote_monitoring.js View on Github external
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

'use strict';

// Azure IoT packages
var Protocol = require('azure-iot-device-http').Http;
var Client = require('azure-iot-device').Client;
var ConnectionString = require('azure-iot-device').ConnectionString;
var Message = require('azure-iot-device').Message;

// Edison packages
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

var hostName        = '';
var deviceId        = '';
var sharedAccessKey = '';

// String containing Hostname, Device Id & Device Key in the following formats:
//  "HostName=;DeviceId=;SharedAccessKey="
var connectionString = 'HostName=' + hostName + ';DeviceId=' + deviceId + ';SharedAccessKey=' + sharedAccessKey;

// Sensor data
var temperature = 0;
var humidity = 0;
var externalTemperature = 0;
github CommonGarden / Grow-IoT / packages / Grow.js / examples / rasp-pi / bioreactor.js View on Github external
setTimeout(()=> {
    // Create a new board object
    const board = new five.Board({
        io: new raspio()
    });

    // When board emits a 'ready' event run this start function.
    board.on('ready', function start() {
        let bioreactor = new Grow({
            uuid: 'meow',
            token: 'meow',
            component: 'BioReactor',
            properties: {
                light_state: null,
                heater: 'off',//1
                airlift: 'off',//2
                aerator: 'off',//3
                water_pump: 'off',//4
                water_level: null,
github elementumscm / workshop-roboticsjs / examples / temperature / temp.js View on Github external
const five = require('johnny-five');

let board = new five.Board();

board.on('ready', () => {

  let temperature = new five.Thermometer({
    controller: 'DS18B20',
    pin: 3,
    freq: 1000
  });

  temperature.on('data', () => {
    console.log(`${temperature.celsius}°C on 0x${temperature.address.toString(16)}`);
  });

});
github rwaldron / johnny-five / eg / arduino-starter-kit / servo-mood-indicator.js View on Github external
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
  io: new Edison()
});

board.on("ready", function() {
  var potentiometer = new five.Sensor("A0");
  var servo = new five.Servo(9);
  potentiometer.on("data", function() {
    console.log(this.value, this.scaleTo(0, 179));
    servo.to(this.scaleTo(0, 179));
  });
});
github stevekinney / nodebots-workshop / example-code / 03-rainbow-led / 03-socket-colors / index.js View on Github external
const path = require('path');

const five = require('johnny-five');
const Tessel = require('tessel-io');
const board = new five.Board({
  io: new Tessel(),
});

board.on('ready', () => {
  const led = new five.Led.RGB({
    pins: {
      red: 'a5',
      green: 'a6',
      blue: 'b5',
    },
  });

  const express = require('express');
  const bodyParser = require('body-parser');
  const app = express();
  const http = require('http').Server(app);
github fivdi / pi-io / example / built-in-led.js View on Github external
'use strict';

const five = require('johnny-five');
const PiIO = require('..');

const board = new five.Board({
  io: new PiIO()
});

board.on('ready', function() {
  const led = new five.Led('LED0');

  led.blink(500);
});
github urish / angular-iot / examples / blink-chip.ts View on Github external
*
 * Copyright (C) 2016, Uri Shaked. License: MIT.
 */

import 'angular2-universal-polyfills';

import { bootstrap } from '../src/index';
const { Board } = require('johnny-five');
var ChipIO = require('chip-io');

import { setPinName } from './blink.component';
import { BlinkModule } from './blink.module';

setPinName('STATUS');

const board = new Board({
    io: new ChipIO()
});

board.on('ready', () => {
  bootstrap(BlinkModule);
});

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

56 / 100
Full package analysis