Back to Parent

int photoCellPin = A0;
int photoCellReading = 0;
int ledPin = D2;
int ledBrightness = 0;

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

}

void loop() {
    
    photoCellReading = analogRead(photoCellPin);
    ledBrightness = map(photoCellReading, 0, 4095, 0, 255);
    analogWrite(ledPin, ledBrightness);
    delay(100);

}
Click to Expand

Content Rating

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

0