-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwitpot.pde
42 lines (34 loc) · 965 Bytes
/
twitpot.pde
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
/*
Tweet-a-pot Donovan Roudabush 2013
Please email changes to [email protected] so I
can improve this code!
Enables blinking/relay control over twitter, using python code
Based off of Blink and Serial demo code
*/
int relayPin = 13; // LED connected to digital pin 13
int incomingByte = 0; //declare incoming byte
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(relayPin, OUTPUT);
Serial.begin(19200); // set up Serial library at 19200 bps
Serial.println("Arduino is ready!");
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
Serial.println(incomingByte);
if (incomingByte == 49){
digitalWrite(relayPin, HIGH);
} else {
digitalWrite(relayPin, LOW);
}
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}