48675_LAB02: Inputs and Sensors

Made by Phoebe

Created: December 4th, 2022

0

Outcome

    • This should provide at least one clear illustration of the final outcome (photo or video as appropriate).
  • It should ideally have several supporting images as well as a video demonstrating the working prototype, circuit diagrams, etc.)
  • Add completed code and any supporting documentation and file (and/or a completed zip folder containing all of your source code)
    • a clear overhead (or top-down) photo of your completed circuit

0
//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
0

Process

Describe the process you underwent to reach the outcome (problems encountered, how you resolved them, as well as, experiments, hacks, tests, refinments, iterations, failures)

0

Reflection

Reflect on the process of making this project. What did you learn? What would you do differently?

0
x