Created
January 27, 2015 23:01
-
-
Save extrasleepy/8054ae63de5718355b18 to your computer and use it in GitHub Desktop.
down Infrared
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 = 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