Skip to content

Instantly share code, notes, and snippets.

@rssilva
Last active November 29, 2015 20:19
Show Gist options
  • Save rssilva/40d1c8755f13582ad6b2 to your computer and use it in GitHub Desktop.
Save rssilva/40d1c8755f13582ad6b2 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});
// Instantiate the module and passes the telegram bot as parameter
johnnyTelegram.init(bot);
// Waits to the Johnny Five board to be ready. To create sensors before it
// probably will cause execution errors
board.on('ready', function () {
// Instantiate a new led on pin 13
var led = new five.Led(13);
// We are adding a led to Johnny-Telegram called 'led' so we have a reference name
// to call on Telegram
johnnyTelegram.add('led', led);
// This method adds a listener to the telegram events
johnnyTelegram.bindEvents();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment