Skip to content

Instantly share code, notes, and snippets.

@pfeerick
Last active September 30, 2016 05:10
Show Gist options
  • Select an option

  • Save pfeerick/da9bec46d17fad1e881c8599dfa9542c to your computer and use it in GitHub Desktop.

Select an option

Save pfeerick/da9bec46d17fad1e881c8599dfa9542c to your computer and use it in GitHub Desktop.
Just s simple script to test some particle stuff on the Oak
/*
Just s simple script to test some particle stuff on the Oak
*/
// this makes the Oak only automatically connect to wifi, not particle
SYSTEM_MODE(SEMI_AUTOMATIC)
// the setup function runs once when you reset or power the board
void setup()
{
// initialize digital pin 1 as an output.
pinMode(1, OUTPUT);
//do some blinks before the particle connection is started
for (int i = 0; i < 5; i++)
{
digitalWrite(1, HIGH); // turn the LED on
delay(500); // wait
digitalWrite(1, LOW); // turn the LED off
delay(500); // wait
}
//connect to particle
if (Particle.connected() == false) {
Particle.connect();
}
//proudly state on particle that "It's alive!"
Particle.publish("event", "Oak is connected to Particle!", PRIVATE);
}
// the loop function runs over and over again forever
void loop()
{
//make the led blink every ~10 seconds
digitalWrite(1, HIGH); // turn the LED on
delay(500); // wait
digitalWrite(1, LOW); // turn the LED off
Particle.publish("event", "Oak LED has blinked!", PRIVATE);
delay(9500); // wait
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment