-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
68 lines (63 loc) · 1.56 KB
/
test.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
62
63
64
65
66
67
68
'use strict';
var five = require('johnny-five');
var board = new five.Board();
var Twitter = require('node-tweet-stream');
var t = new Twitter({
consumer_key: '8Q9T8yWUaPHnqgRTAnS1maR5K',
consumer_secret: 'XcThyabsygUQPfJHpOQfFJttyjOVg3zITEwj4pRROExzcCU8K1',
token: '44652089-f3Y09zedoTIRilolC6tIJYrQZ5yp2yS17ijxUwRzk',
token_secret: '85tIzY4XSYn4n5lrkokWpHzm5PnjIUW0y7EbEM0oHh3nk'
});
var busy = false;
var subirIndio = function(servo, piezo, theSong) {
if (!busy) {
servo.to(0);
piezo.play({
tempo: 1700,
song: theSong
});
busy = false;
}
};
var bajarIndio = function(servo, piezo, theSong) {
if (!busy) {
servo.to(180, 1200);
piezo.play({
tempo: 1700,
song: theSong
});
busy = false;
}
};
board.on('ready', function() {
var servo = new five.Servo({
pin: 10,
startAt: 180
});
var piezo = new five.Piezo({
pin: 11
});
var theSongUp = [];
var theSongDown = [];
for (var i = 500; i < 1000; i += 10) {
theSongUp.push([
i, 1
]);
theSongDown.push([
1000 - i, 1
]);
}
t.on('tweet', function(tweet) {
if (tweet.text.toLowerCase().indexOf('levantate') > -1) {
//SUBIR INDIO PICARO
subirIndio(servo, piezo, theSongUp);
} else if (tweet.text.toLowerCase().indexOf('bajate') > -1) {
//BAJAR INDIO PICARO
bajarIndio(servo, piezo, theSongDown);
}
});
t.on('error', function(err) {
console.log('Oh no');
});
t.track('@indiopicaro_js');
});