Created
November 21, 2014 11:59
-
-
Save nkint/5702a2dd7fdd853bcdd3 to your computer and use it in GitHub Desktop.
Arduino read the key-value from Bridge
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 <Bridge.h> | |
unsigned long timer; | |
unsigned long counter = 0L; | |
void setup() | |
{ | |
Serial.begin(9600); | |
Bridge.begin(); // this launches /usr/bin/run-bride on Linino | |
timer = millis(); | |
pinMode(13, OUTPUT); | |
} | |
void loop() | |
{ | |
/* Every 200ms: */ | |
if (millis() - timer > 200) { | |
timer = millis(); | |
char myData[100]; | |
Bridge.get("msg", myData, 100); | |
int n; | |
n = atoi(myData); | |
Serial.println(n); | |
if(n!=0) { | |
digitalWrite(13, HIGH); | |
Serial.println("on!"); | |
delay(1000); | |
Serial.println("off"); | |
Bridge.put("msg", 0); | |
digitalWrite(13, LOW); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment