-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (49 loc) · 1.41 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var express = require('express')
, twitter = require('ntwitter')
, j5 = require("johnny-five")
var twit = new twitter({
consumer_key: 'oXAbKQyQ47h9CBVXmMGdQ',
consumer_secret: 'z9EqbFpf4dhNuY6M1Eawk3W2dwnt9B1PoQRAMyWtxTU',
access_token_key: '15524875-L916RzSGVMqi1DlZz4MiB7RCgsWhuKSsD9T7Pn5i1',
access_token_secret: 'GLMDBi2NFYl3eZmUZ4zmhphDMozXesMN16DI9NOaIo'
});
var app = express()
, tweet
, board = new j5.Board();
app.listen(3000);
board.on("ready", function() {
setInterval(
function(){
twit.getUserTimeline( { screen_name : "sarajchipps" , count : 1 } ,
function (err, data) {
red = new j5.Led(11);
green = new j5.Led(9);
blue = new j5.Led(10);
var leds = new j5.Leds();
tweet = data[0].text;
if(tweet.indexOf('hate') != -1){
console.log("hate!");
red.off();
green.on();
blue.on();
}
else if(tweet.indexOf('happy') != -1){
console.log("happy");
red.on();
green.on();
blue.off();
}
else{
console.log('nothing!');
red.on();
green.off();
blue.on();
}
}
)}, 5000);
});
/*twit.stream('statuses/sarajchipps', function(stream) {
stream.on('data', function (data) {
console.log(data);
});
}); */