Commit 86e75f3f authored by ssshroff's avatar ssshroff
Browse files

Working version

parent ac6624fb
const int trigPin1 = 9;
const int echoPin1 = 8;
const int trigPin2 = 6;
const int echoPin2= 7;
long duration1;
long duration2;
int distance1;
int distance2;
void setup() {
// put your setup code here, to run once:
pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin1, INPUT); // Sets the echoPin as an Input
pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin2, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigPin1, LOW);
digitalWrite(trigPin1, HIGH);
digitalWrite(trigPin1, LOW);
duration1 = pulseIn(echoPin1, HIGH);
distance1 = duration1 * 0.034/2;
Serial.print("Sensor 1:");
digitalWrite(trigPin2, LOW);
digitalWrite(trigPin2, HIGH);
digitalWrite(trigPin2, LOW);
duration2 = pulseIn(echoPin2, HIGH);
distance2 = duration2 * 0.034/2;
Serial.print("Sensor 2:");
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment