Skip to content

Instantly share code, notes, and snippets.

@WickedDevice
Created December 13, 2015 19:57
Show Gist options
  • Save WickedDevice/b98ff54d9a15dc2fa884 to your computer and use it in GitHub Desktop.
Save WickedDevice/b98ff54d9a15dc2fa884 to your computer and use it in GitHub Desktop.
Button LED test for Wearable
int buttonPin=D5;
int led1=D4;
// The code in setup() runs once when the device is powered on or reset. Used for setting up states, modes, etc
void setup() {
// Tell b to get everything ready to go
//pinMode(buttonPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP);
pinMode(led1, OUTPUT);
digitalWrite(led1, HIGH);;
delay(100);
digitalWrite(led1, LOW);
}
/* loop(), in contrast to setup(), runs all the time. Over and over again.
Remember this particularly if there are things you DON'T want to run a lot. Like Spark.publish() */
void loop() {
if(digitalRead(buttonPin) == LOW){
Particle.publish("button_status","true");
digitalWrite(led1, HIGH);;
delay(100);
digitalWrite(led1, LOW);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment