I'm working on a robot using a Rev B board that will move around autonimously and avoid collision using HC-SR04 ultrasonic range finders. I've already got it working with a single sensor facing directly ahead but I want to add two more looking 90 degrees to the left and right as well so the robot can make a decision based on which direction determines an obstacle to be farthest away. I'm already starting to sort out the code as that part is pretty easy after getting it to work with a single sensor, but what I'm wondering is if I can connect all three pulse pins to a single GPIO out and have the Echo pins connected to their own GPIO in. The thought is that I would run some code to "Look around" and pulse once and listen on the left echo, grab that number, pulse again and listen on the center echo, grab that number and pulse again and listen on the right echo and return each of those values. If I'm only listening on one echo, am I still going to get weird numbers with all of them pulsing at the same time and bouncing the signal or is it safe to assume that I'm not going to pick up an echo from the ultrasound on the right before the one on the left assuming left is what I am listening on?
If I'm going to connect these each to their own GPIO out and GPIO in, obviously I will need a total of six GPIO pins for the three sensors. I'm already using a total of six for my H-Bridge motor driver using an L293D to drive two 6-vold DC motors for the wheels. It looks like it's possible but I'm still pretty new to the GPIO so I want to make sure there's not some reason i can't use certain pins. The H-bridge has already been soldered to a perf board, but I have the L293D in a socket so it can be taken out if I need to go back to a breadboard for this. It's currently set up to use GPIO 19, 21 and 23 for one side of the bridge, and GPIO 16,18 and 22 for the other side. Could I, for example use GPIO 3 as my pulse pin and use 5, 7 and 11 for all of my echo pins or would it be better to just do dedicated pulse and echo pins for each of the HC-SR04 range finders?
I would greatly appreciate any feedback anybody has on this though I will say, for this project I want to stick to a 26 pin GPIO bus rather than upgrading to a B+ or one of the other boards with a 40 pin bus. I intend to use the knowledge to teach others how to build a basic robot at my local maker space this summer provided we get all of our non-profit stuff settled in time.
Thanks everybody.
