#define left_echoPin 2 // Pin to receive echo pulse
#define left_trigPin 3 // Pin to send trigger pulse
#define right_echoPin 4 // Pin to receive echo pulse
#define right_trigPin 5 // Pin to send trigger pulse
void setup(){
Serial.begin(115200);
pinMode(left_echoPin, INPUT);
pinMode(left_trigPin, OUTPUT);
pinMode(right_echoPin, INPUT);
pinMode(right_trigPin, OUTPUT);
}
void loop(){
byte a=aisthitirio_left();
byte b=aisthitirio_right();
Serial.print("Left ");
Serial.print(a);
Serial.print(" Right ");
Serial.print(b);
delay(5000);
}
// Auth h synarthsh epistrefei thn apostash toy aristera empodioy se cm h 50000 an den yparxei empodio
byte aisthitirio_left()
{
digitalWrite(left_trigPin, LOW); // Set the trigger pin to low for 2uS
delayMicroseconds(2);
digitalWrite(left_trigPin, HIGH); // Send a 10uS high to trigger ranging
delayMicroseconds(10);
digitalWrite(left_trigPin, LOW); // Send pin low again
int distance = pulseIn(left_echoPin, HIGH); // Read in times pulse
distance= distance/58;
byte mes=(byte) distance;
delay(50); // Wait 50mS before next ranging
return(mes);
}
// Auth h synarthsh epistrefei thn apostash toy deksioy empodioy se cm h 50000 an den yparxei empodio
byte aisthitirio_right()
{
digitalWrite(right_trigPin, LOW); // Set the trigger pin to low for 2uS
delayMicroseconds(2);
digitalWrite(right_trigPin, HIGH); // Send a 10uS high to trigger ranging
delayMicroseconds(10);
digitalWrite(right_trigPin, LOW); // Send pin low again
int distance = pulseIn(right_echoPin, HIGH); // Read in times pulse
distance= distance/58;
byte mes=(byte) distance;
delay(50); // Wait 50mS before next ranging
return(mes);
}
#define left_trigPin 3 // Pin to send trigger pulse
#define right_echoPin 4 // Pin to receive echo pulse
#define right_trigPin 5 // Pin to send trigger pulse
void setup(){
Serial.begin(115200);
pinMode(left_echoPin, INPUT);
pinMode(left_trigPin, OUTPUT);
pinMode(right_echoPin, INPUT);
pinMode(right_trigPin, OUTPUT);
}
void loop(){
byte a=aisthitirio_left();
byte b=aisthitirio_right();
Serial.print("Left ");
Serial.print(a);
Serial.print(" Right ");
Serial.print(b);
delay(5000);
}
// Auth h synarthsh epistrefei thn apostash toy aristera empodioy se cm h 50000 an den yparxei empodio
byte aisthitirio_left()
{
digitalWrite(left_trigPin, LOW); // Set the trigger pin to low for 2uS
delayMicroseconds(2);
digitalWrite(left_trigPin, HIGH); // Send a 10uS high to trigger ranging
delayMicroseconds(10);
digitalWrite(left_trigPin, LOW); // Send pin low again
int distance = pulseIn(left_echoPin, HIGH); // Read in times pulse
distance= distance/58;
byte mes=(byte) distance;
delay(50); // Wait 50mS before next ranging
return(mes);
}
// Auth h synarthsh epistrefei thn apostash toy deksioy empodioy se cm h 50000 an den yparxei empodio
byte aisthitirio_right()
{
digitalWrite(right_trigPin, LOW); // Set the trigger pin to low for 2uS
delayMicroseconds(2);
digitalWrite(right_trigPin, HIGH); // Send a 10uS high to trigger ranging
delayMicroseconds(10);
digitalWrite(right_trigPin, LOW); // Send pin low again
int distance = pulseIn(right_echoPin, HIGH); // Read in times pulse
distance= distance/58;
byte mes=(byte) distance;
delay(50); // Wait 50mS before next ranging
return(mes);
}