I have a B+ connected to a H-bridge which is connected to 4 AA batteries and 4 motors, and they work fine, but now I want to add a distance sensor, which requires 5v, so do I need any extra batteries?
1 Answer
You can use the 5v output on the gpios of the Raspberry Pi. However be careful, you mustn't connect the echo pin directly to the gpio. Instead you can make a voltage divider on the wire connecting the echo pin because the b+ can't handle anything over 3.3v. Not using a voltage divider will damage your Raspberry Pi.
You can use a 470 Ohm and a 1K Ohm resistor with the 1K connecting echo and ground. Refer to the diagram below if you are unsure. 
- My tutorial just uses just a 1 kilo ohm resistor, is that okay?Vedbot– Vedbot2015-10-25 14:38:12 +00:00Commented Oct 25, 2015 at 14:38
- @Vedbot It is risky, I can't guarantee the voltage will be around 3.3v without a voltage divider. Maybe someone else can tell you.Linus– Linus2015-10-25 14:46:56 +00:00Commented Oct 25, 2015 at 14:46
- The official line has always been that any current at a voltage greater than 3.3V will eventually kill the GPIO/Pi. I can't see the official line changing. A voltage divider is safest. If you can only use 1 resistor I suggest a value of 10k or more.joan– joan2015-10-25 14:52:47 +00:00Commented Oct 25, 2015 at 14:52