Back to Parent

int ledPin = D3;

int switchPin = D4;
int photoCellPin = A3;
int photoCellReading = 0;
int ledBrightness = 0;


void setup() {
    pinMode( switchPin, INPUT_PULLUP);
    pinMode( ledPin, OUTPUT);
    
    Particle.variable("light", &photoCellReading, INT);
    

}

void loop() {
    
    int buttonState = digitalRead( switchPin);
    photoCellReading = analogRead(photoCellPin);
    
    if(buttonState == HIGH) {
        if (photoCellReading <= 2000) {
        digitalWrite( ledPin, HIGH);
        }else{
            digitalWrite( ledPin, LOW);
            }
    }else{
        digitalWrite( ledPin, LOW);
    }

}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0