Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
Created February 9, 2013 13:41
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 laclefyoshi/4745322 to your computer and use it in GitHub Desktop.
Save laclefyoshi/4745322 to your computer and use it in GitHub Desktop.
int focusPin = 2;
int shutterPin = 3;
void setup() {
pinMode(focusPin, OUTPUT);
pinMode(shutterPin, OUTPUT);
pinMode(13, OUTPUT);
}
int v = 0;
int threshold = 20;
int d = 30000;
void initPin() {
digitalWrite(focusPin, LOW);
digitalWrite(shutterPin, LOW);
digitalWrite(13, LOW);
}
void loop() {
initPin();
int v = analogRead(0);
if (v > threshold) {
digitalWrite(13, HIGH);
digitalWrite(focusPin, HIGH);
delay(1000);
digitalWrite(focusPin, LOW);
delay(500);
digitalWrite(shutterPin, HIGH);
delay(500);
initPin();
delay(d);
}
delay(500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment