Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define trigpin 3
- #define echopin 2
- void setup()
- {
- Serial.begin(9600);
- pinMode(trigpin,OUTPUT);
- pinMode(echopin, INPUT);
- }
- void loop()
- {
- int distance, duration; //I even tried putting long instead of int
- digitalWrite(trigpin,HIGH);
- delayMicroseconds(10);
- digitalWrite(trigpin,LOW);
- while (digitalRead(echopin) == LOW) {
- //the controller will do nothing until the echo pin pauses
- }
- Serial.println("Clear");
- }
Advertisement
Add Comment
Please, Sign In to add comment