Skip to content

Instantly share code, notes, and snippets.

@grundyoso
Created July 29, 2019 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grundyoso/022e8524f7e5e277d3201e57d6505025 to your computer and use it in GitHub Desktop.
Save grundyoso/022e8524f7e5e277d3201e57d6505025 to your computer and use it in GitHub Desktop.
Arduino sketch for LightBlue Bean for PyroPalma project
#define PYRORLY 5
#define PYROBTN 13
void setup() {
Serial.begin();
Serial.setTimeout(5);
pinMode(PYRORLY, OUTPUT);
digitalWrite(PYRORLY, HIGH);
}
void loop() {
// Check for serial mesaages
char buf[64];
size_t len = 64;
len = Serial.readBytes(buf, len);
if ( len > 0 ) {
Bean.setLedRed(30);
for (int i=0; i < len-1; i+=2) {
if (buf[i]==PYROBTN && buf[i+1]==0){
Bean.setLedGreen(155);
digitalWrite(PYRORLY,HIGH);
}
else if (buf[i]==PYROBTN && buf[i+1]==1){
Bean.setLedGreen(0);
digitalWrite(PYRORLY,LOW);
}
}
}
Bean.setLedRed(0);
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment