Steven Gu
Published

The Light That Brightened The Gac

Gac'd Out.

ExpertWork in progressOver 1 day257
The Light That Brightened The Gac

Things used in this project

Hardware components

RGB Diffused Common Cathode
RGB Diffused Common Cathode
×1
LilyPad Button Board
SparkFun LilyPad Button Board
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×2
Breadboard (generic)
Breadboard (generic)
×1
Photon
Particle Photon
×1
Resistor 221 ohm
Resistor 221 ohm
×3
Wire Cable - By the Foot
OpenBuilds Wire Cable - By the Foot
×1

Software apps and online services

Particle Pi
Particle Pi
Maker service
IFTTT Maker service
Android Things
Google Android Things

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

Blink an LED

C/C++
int led1 = D2;
int led2 = D3;
int red = D4;
int green = D5;
int blue = D6;

void setup()
{
   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);
   pinMode(red, OUTPUT);
   pinMode(green, OUTPUT);
   pinMode(blue, OUTPUT);
   Particle.function("led",ledToggle);
  
   digitalWrite(led1, LOW);
   digitalWrite(led2, LOW);
   digitalWrite(red, LOW); 
   digitalWrite(green, LOW);
   digitalWrite(blue, LOW);

}

void loop()
{
  
}

int ledToggle(String command) {
   

    if (command=="on") {
        digitalWrite(led1,HIGH);
        digitalWrite(led2,HIGH);
        return 1;
    }
    else if (command=="off") {
        digitalWrite(led1,LOW);
        digitalWrite(led2,LOW);
        digitalWrite(red, LOW); 
        digitalWrite(green, LOW);
        digitalWrite(blue, LOW);
        return 0;
    } else if (command=="red") {
        digitalWrite(red, HIGH);
        return 2;
    } else if (command=="green") {
        digitalWrite(green, HIGH);
        return 3;
    } else if (command=="blue") {
        digitalWrite(blue, HIGH);
        return 4;
    } else {
        return -1;
    }

}
    

Credits

Steven Gu

Steven Gu

1 project • 0 followers
Thanks to Alejandro Tonda and Sarah Shi, Maya Nichols, Catherine Li.

Comments

Add projectSign up / Login