int ledPin = D2;
int photoresPin = A4;
int photoresRead = 0;
void setup() {
//Set the LED as Output
pinMode(ledPin, OUTPUT);
Particle.variable("photoResValue", photoresRead);
}
void loop() {
//0-4095
photoresRead = analogRead(photoresPin);
//using map function to convert the range
int brightness = map(photoresRead, 0 , 4095, 0, 255 );
analogWrite( ledPin, brightness );
delay(200);
}
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. .