int sensorPin = A0;
int sensorReading = 0;
int ledPin = D1;
int ledBrightness = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Particle.variable("light", &sensorReading, INT);
Particle.variable("brightness", &ledBrightness, INT);
}
void loop() {
sensorReading = analogRead(sensorPin);
Serial.println(sensorReading);
if (sensorReading < 3700) {
ledBrightness = 255;
} else {
ledBrightness = 0;
}
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!
You must login before you can post a comment. .