/* Utilisation du capteur Ultrason HC-SR04 */ // définition des broches utilisées int trigA = 7; int echoA = 6; int trigB = 7; int echoB = 5; long timeAB; long timeBA; long C; long V; long speedofsoundmps = 340; void setup() { pinMode(trigA, OUTPUT); digitalWrite(trigA, LOW); pinMode(echoA, INPUT); pinMode(trigB, OUTPUT); digitalWrite(trigB, LOW); pinMode(echoB, INPUT); Serial.begin(9600); } void loop() { digitalWrite(trigA, LOW); delayMicroseconds(2); digitalWrite(trigA, HIGH); delayMicroseconds(10); digitalWrite(trigA, LOW); timeAB = pulseIn(echoB, HIGH); //timeAB = timeAB-40; //Serial.println("Temps AB : "); //Serial.println(timeAB); delay(100); digitalWrite(trigB, LOW); delayMicroseconds(2); digitalWrite(trigB, HIGH); delayMicroseconds(10); digitalWrite(trigB, LOW); timeBA = pulseIn(echoA, HIGH); //timeBA = timeBA-40; //Serial.println("Temps BA : "); //Serial.println(timeBA); C = (0.45/2)*((1e6/timeAB)+(1e6/timeBA)); V = (0.45/2)*((1e6/timeAB)-(1e6/timeBA)); //Serial.println("Vitesse c : "); //Serial.println(C); //Serial.println() ; Serial.println("Vitesse du vent V : "); Serial.println(V); Serial.println(); //Serial.println(); //Serial.println(); delay(1000); }