Skip to content

Commit

Permalink
added quick & dirty test sketch
Browse files Browse the repository at this point in the history
  • Loading branch information
jp112sdl committed Sep 9, 2018
1 parent 6880aeb commit 147b68f
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions distance_test/distance_test.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const int pwPin1 = 6;
long sensor;

void setup() {
Serial.begin(57600);
pinMode(5, OUTPUT);
pinMode(pwPin1, INPUT);
}

void read_sensor () {
digitalWrite(5, HIGH);
delay(300);
sensor = pulseIn(pwPin1, HIGH);
digitalWrite(5, LOW);

}

void print_range() {
Serial.print("S1");
Serial.print("=");
Serial.print( sensor);
Serial.print(", ");
Serial.println( (sensor * 1000L / 57874L));
}

void loop() {
read_sensor();
print_range();
delay(100);
}

0 comments on commit 147b68f

Please sign in to comment.