Created
July 29, 2019 18:27
-
-
Save grundyoso/022e8524f7e5e277d3201e57d6505025 to your computer and use it in GitHub Desktop.
Arduino sketch for LightBlue Bean for PyroPalma project
This file contains 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
#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