Skip to content

Instantly share code, notes, and snippets.

@extrasleepy
Created January 27, 2015 23:01
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 extrasleepy/8054ae63de5718355b18 to your computer and use it in GitHub Desktop.
Save extrasleepy/8054ae63de5718355b18 to your computer and use it in GitHub Desktop.
down Infrared
int sensorpin = 2;
int time = 0;
//to hold the time it took for the cap to discharge
void setup() {
Serial.begin(9600);
// For Printing the time it took for the cap to discharge to me
}
void loop() {
time = 0;
pinMode(sensorpin, OUTPUT);
digitalWrite(sensorpin, HIGH);
delayMicroseconds(10);
pinMode(sensorpin, INPUT);
while(digitalRead(sensorpin) == HIGH) {
time++;
if (time>1000){
goto moveon;
}
}
moveon:
Serial.println(time);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment