Skip to content

Instantly share code, notes, and snippets.

@nkint
Created November 21, 2014 11:59
Show Gist options
  • Save nkint/5702a2dd7fdd853bcdd3 to your computer and use it in GitHub Desktop.
Save nkint/5702a2dd7fdd853bcdd3 to your computer and use it in GitHub Desktop.
Arduino read the key-value from Bridge
#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