Skip to content

Instantly share code, notes, and snippets.

@nburn42
Created May 10, 2017 18:49
Show Gist options
  • Save nburn42/12f0f64303547abd7e834b57d29d4369 to your computer and use it in GitHub Desktop.
Save nburn42/12f0f64303547abd7e834b57d29d4369 to your computer and use it in GitHub Desktop.
float pulsewidth = 10; // 1/100 a second
long count = 0;
long goal = 1024;
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
delay(pulsewidth);
count = 0;
do {
if(analogRead(A2) > 500) {
goal = analogRead(A0);
}
delay(pulsewidth);
count += 15;
} while(count < goal);
digitalWrite(13, HIGH);
delay(pulsewidth);
digitalWrite(13, LOW);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment