Skip to content

Instantly share code, notes, and snippets.

@schlerp
Created August 8, 2017 06:24
Show Gist options
  • Save schlerp/c9948bd6ca12a1983cbea1709c4d8c05 to your computer and use it in GitHub Desktop.
Save schlerp/c9948bd6ca12a1983cbea1709c4d8c05 to your computer and use it in GitHub Desktop.
void setup () {
// do what ever to get it all set up
// only ran once at poweron
}
void main () {
if (sensorpin is low && analogread value less than x) {
set pin high
}
if (sensorpin high && analogread value above y) {
set pin back down to low
}
//when it gets to here it goes back to the start of the main loop.
// so it might try those statements 1000 times before the sensorvalue
// gets high enough for the second if statement to switch the pin back down
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment