obniz developer team
Published © GPL3+

Move a Flag When You Receive a Comment on Twitter!

The flag moves when #keyword is tweeted. Integration of Twitter and obniz is easy to do. Move the flag when you've got a tweet.

BeginnerFull instructions provided4 hours622

Things used in this project

Hardware components

obniz
Cambrian Robotics obniz
×1
Adafruit Servo motor
×1
Flag
×1
Battery or USB adaptor & cable
×1

Software apps and online services

Twitter
Twitter

Story

Read more

Schematics

wired_HcnAELH2Oj.png

Code

Program

JavaScript
// Nodejs

var Obniz = require('obniz');
var Twitter = require('twitter');

var obniz = new Obniz("0000-0000");
 
obniz.onconnect = function(){
  var servo = obniz.wired("ServoMotor", {signal:0,vcc:1, gnd:2});
  servo.angle(10);
}
 
var client = new Twitter({
  consumer_key: '<ConsumerKey>',
  consumer_secret: '<Secret>',
  access_token_key: '<TokenKey>',
  access_token_secret: '<TokenSecret>'
});
 
var stream = client.stream('statuses/filter',
 {track: '#obniz'});
stream.on('data', function(event) {
  if (event) {
    var count = 0;
    var angles = [10,50,10,50,10,50,10]
    var timer = setInterval(function(){
      count++;
      servo.angle(angles[count]);
      if (count >= 6){
        clearInterval(timer);
      }
    }, 1000);
  }
});

Credits

obniz developer team
80 projects • 35 followers
Development board "obniz" is controlled via the internet.
Contact

Comments

Please log in or sign up to comment.