Created
October 17, 2013 05:32
-
-
Save aaronsherwood/7019570 to your computer and use it in GitHub Desktop.
arduino code for this: http://aaron-sherwood.com/blog/?p=1007
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int sensorPin = A0; | |
int buttonPin = 2; | |
int ledPin = 12; | |
int sensorValue = 0; | |
int buttonValue = 0; | |
int count = 0; | |
int target_wraps = 10; | |
bool check = true; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(ledPin, OUTPUT); | |
pinMode(buttonPin, INPUT); | |
} | |
void loop() { | |
sensorValue = analogRead(sensorPin); | |
buttonValue = digitalRead(buttonPin); | |
if (sensorValue > 900 && check == true) { | |
count++; | |
check=false; | |
} | |
if (sensorValue < 900) { | |
check=true; | |
} | |
if (buttonValue==1){ | |
digitalWrite(ledPin, LOW); | |
count=0; | |
} | |
if (count>target_wraps-1) { | |
digitalWrite(ledPin, HIGH); | |
} | |
Serial.println(sensorValue); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment