int sensorsPins[NUMBER_OF_SENSORS] = {2, 11, 12, A0, A1, A2, A3}; //define the pins for the sensors
loop ()
{
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration = pulseIn(sensorsPins[currentSensor], HIGH, 4000);
currentSensor = (currentSensor+1)%7;
delay(1000)
}
Comments