Back to Parent

//Modify the program so that the LED shows the opposite. 
//When there is little light, it will be bright and when there’s lots of light, it will be off.

int photoCellPin = A3;
int photoCellReading = 0;
int ledPin = D3;
int ledBrightness = 0;


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

}

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

}

//1300 is around the lowest light value  I can get for dark conditions
//3700 is around the highest light value I can get for normal room lighting
Click to Expand

Content Rating

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

0