//PHOEBE DEGROOT -
//
//written for Particle Argon
int Plight = A0;
int PLED = D2;
int bright;
int photocellRead;
int thresholdDark = 100;
int photMax = 4095;
int photMin = 10;
int readLight(int pin){
int read;
read = analogRead(pin);
return read;
}
void setup() {
pinMode(PLED, OUTPUT);
Particle.variable("Light", &photocellRead, INT);
}
void loop() {
photocellRead = readLight(Plight);
bright = map(readLight(Plight), photMin, photMax, 0, 255);
controlLight(bright);
delay(100);
}
void controlLight(int input){
if (input< thresholdDark){
digitalWrite(PLED,HIGH);
}
else{
digitalWrite(PLED, LOW);
}
}
Click to Expand