Created
April 17, 2012 14:59
-
-
Save ffaerber/2406546 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Servo.h> | |
| #include <SPI.h> | |
| #include <Ethernet.h> | |
| #include <PusherClient.h> | |
| byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; | |
| PusherClient client; | |
| int ledPin = 13; // LED connected to digital pin 13 | |
| void setup() { | |
| pinMode(ledPin, OUTPUT); // sets the digital pin as output | |
| Serial.begin(9600); | |
| if (Ethernet.begin(mac) == 0) { | |
| Serial.println("Init Ethernet failed"); | |
| for(;;) | |
| ; | |
| } | |
| if(client.connect("fda87b0ca6c5042a1e4d")) { | |
| client.bind("led_on", ledOn); | |
| client.bind("led_off", ledOff); | |
| client.subscribe("weblightz"); | |
| } | |
| else { | |
| while(1) {} | |
| } | |
| } | |
| void loop() { | |
| if (client.connected()) { | |
| client.monitor(); | |
| digitalWrite(ledPin, HIGH); | |
| } | |
| else { | |
| digitalWrite(ledPin, LOW); | |
| } | |
| } | |
| void ledOn(String data) { | |
| digitalWrite(ledPin, HIGH); | |
| } | |
| void ledOff(String data) { | |
| digitalWrite(ledPin, LOW); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment