Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@rssilva
Created November 29, 2015 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rssilva/5a86fac00ac427c4494e to your computer and use it in GitHub Desktop.
Save rssilva/5a86fac00ac427c4494e to your computer and use it in GitHub Desktop.
var johnnyTelegram = require('../src/johnny-telegram.js');
var five = require('johnny-five');
var TelegramBot = require('node-telegram-bot-api');
var board = new five.Board();
var token = 'YOUR_TELEGRAM_API_TOKEN';
var bot = new TelegramBot(token, {polling: true});
johnnyTelegram.init(bot);
board.on('ready', function () {
// Instantiate a proximity sensor
var proximity = new five.Proximity({
controller: 'HCSR04',
pin: 7
});
// Adds a sensor named 'prox'
johnnyTelegram.add('prox', proximity);
// Everytime that this sensor have data, we call the Johnny-Telegram 'setValue' method
// setting the 'prox' sensor stored value
proximity.on('data', function() {
johnnyTelegram.setValue('prox', this.cm);
});
johnnyTelegram.bindEvents();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment