Skip to content

Instantly share code, notes, and snippets.

@jasonnerothin
Created February 28, 2018 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonnerothin/dc59432476cb481e200022b65c3af014 to your computer and use it in GitHub Desktop.
Save jasonnerothin/dc59432476cb481e200022b65c3af014 to your computer and use it in GitHub Desktop.
resistor_algo.cpp
// ...And we will take two more readings.
int on_1 = analogRead(photoresistor); // read photoresistor
delay(200); // wait 200 milliseconds
int on_2 = analogRead(photoresistor); // read photoresistor
delay(300); // wait 300 milliseconds
intactValue = (on_1+on_2)/2;
brokenValue = (off_1+off_2)/2;
beamThreshold = (intactValue+brokenValue)/2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment