EldaveO / Learning-Arduino

Contains all my basic Baby Arduino projects
1 stars 2 forks source link

Project 6 --- What happens when the values are equal #7

Closed jameshughes89 closed 3 years ago

jameshughes89 commented 3 years ago

WIthout knowing the details of what this is supposed to do, there is a potential area to look in #6 within "Project06.ino":

    SensorValue = analogRead(A0);
    if (SensorValue > SensorHigh)
    {
      SensorHigh = SensorValue; 
    }
    if (SensorValue < SensorLow)
    {
      SensorLow = SensorValue;
    }

What should happen if SensorValue == SensorHigh? Maybe it should be doing nothing, but I thought I would point it out either way.

EldaveO commented 3 years ago

This portion of the code is meant to spend the first 5 seconds after boot-up to attempt to calibrate the sensor with finger movements. Since I'm using a photoresistor with constantly changing values every cycle it would be extremely unlikely for these values to be equal for more than a single cycle.

An exception case could be used, but I'm not sure if it would provide any value to the calibration function.