talofer99 icon

ultrasonic

talofer99 | PRO | 10/26/22 05:28:19 PM UTC | 0 ⭐ | 254 👁️ | Never ⏰ | []
text |

450 B

|

None

|

0 👍

/

0 👎

 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