Hi,
I'm student of robotics and our teacher asked us to do a 3 ultrasound sensor circuit/system on Wokwi using Arduino Uno. He told us that it wouldn't work because of pulseIn, he also requested us to use libraries (<Ultrasound.h>, <NewPing.h>, <LiquidCrystal.h>. I've been looking for solutions and I didn't find anything. Here's the only code that I have:
Detect the distance and if it's nearby the LED will turn ON. Later we will do a smartcane (the one that blind people use) se we have to make this work, but it only reads the first one
does your code of post #1 work OK with one sensor?
the problem is pulsein will only work with one sensor
you will have to trigger the three sensosr and measure the width of each pulse concurrently using millis()
I suggest changing the code of post #1 to use mills() then extend it to three sensors
I was going to do that, my teacher wouldn't accept the answe if I don't understand it. A couple of days ago we worked with arrays so I understand it!!! Thank you!!!
(Sorry if I make some mistakes or I don't explain it with the right words, I'm not an English speaker)
We made a boolean variable that its values are true or false. The name of this variable is isNearby and we say it's false. I never worked with this variable I'm trying to find what true or false means in this variable. Then that line means that isNearby means that the distance is less than 100cm
Correct, but now there are 3 distance values from the 3 sensors. That code line executes 3 times for each execution of loop(). The led is only updated once, and it is lit if any one of the 3 distances are less than 100cm. How does that line of code combine the 3 distances?
Because we did two arrays with the outputs and the inputs at the beginning and then we did a for loop with the letter s. Then we did a float variable called distance where we put that its meaning is readDistanceCM(s). The s is the for loop and we defined readDistanceCM before with the outputs and the inputs. When we give isNearby a meaning we use the variable that we created (distance).