Things used in this project

Code

PhotonGroveRelayArduino
#define BUTTONPIN D2
#define LEDPIN D7
#define RELAYPIN D4

void setup() {
    pinMode(LEDPIN, OUTPUT);
    pinMode(BUTTONPIN, INPUT);

    pinMode(RELAYPIN, OUTPUT);
    digitalWrite(RELAYPIN, LOW);
}

void loop() {
    if (digitalRead(BUTTONPIN) == 1) {
        digitalWrite(LEDPIN, HIGH);
        digitalWrite(RELAYPIN, HIGH);
    } else {
        digitalWrite(LEDPIN, LOW);
        digitalWrite(RELAYPIN, LOW);
    }
}

Credits

Zzlcgbnzwko5lq80k1x1
An Tran
5 projects • 8 followers
tech, startup, web, mobile, iot, dev
Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Add projectSign up / Login