New to Arduino, need more than one Power?

Hello all,
For my first project I succesfully made a motion detector using Motion PIR and MEGA 2560. I would like to add a second sensor to the same unit (Sonar), so I can have the microcontroller notify the Pi that whatever it is detecting is really close (since I believe the max range for Sonar is 3 feet).

I only have one 5V supply. Is my only option to cut the wire and piggy back off the same pin? I'm sorry for the lack of correct terminology as I just started learning last week. Also, is it even possible to have two sensors on a single core microcontroller since we can't multithread?

Thank you

You can make these:

Yes you can have multiple sensors.
You can scan them one at a time, very fast ;).
You can write a ‘state machine’ and change your code execution as needed.

Thank you for your response! So in terms of code, based on your response, the logic would be like this?

Loop{
 checkSensor1()
 checkSensor2()
}

As for the Power Question, forgive me but I don’t know what’s going on in any of those photos. Could you kindly explain number 1?

The first image has a 2nd connector piggybacked/soldered onto the first.
Plugging this assembly into your Arduino header now gives 2 female pins for each header pin.

You could solder a third connector on the opposite side which would give 3 female pins for every header pin.

The second image should be self explanatory.

The third image shows an IDC connector with a wire zigzagging through all pins, therefore one input pin becomes 10.

Depending on the sensors, your assumption on programming would be correct.

larryd:
The first image has a 2nd connector piggybacked/soldered onto the first.
Plugging this assembly into your Arduino header now gives 2 female pins for each header pin.

You could solder a third connector on the opposite side which would give 3 female pins for every header pin.

The second image should be self explanatory.

The third image shows an IDC connector with a wire zigzagging through all pins, therefore one input pin becomes 10.

Depending on the sensors, your assumption on programming would be correct.

Thank you. I've taken your advice and sort of did #1 (it works). I just find it hard to believe that more people don't have this problem, and there aren't more adapters/devices to resolve this issue.

There are 2 5V pins at one end of the dual row header on a Mega by pins 22 and 23.

Are you referring to this, where I am pointing? I thought it said 54, not 5V..


Not sure if the image will load. If not: 4-D62-F8-A9-913-B-4-EFE-90-B1-2-CD66-DA4-F704 hosted at ImgBB — ImgBB

Your link did not work. Here is how to post an image.

Here is where the 5V is available on the dual row header of the Mega. The 2 terminals at the other end of the header are ground. Also, there is a 5V and ground available on the ICSP connector.
mega 5V.jpg

mega 5V.jpg

I reuploaded the image. When I get home from work I’ll try to see if I can find what you’re showing me. That diagram is for a 2560, correct?

(I appreciate your time and patience)

You have 4 female options on a REV3 Mega2560:

That diagram is for a 2560, correct?
Yes, it is a portion of this diagram.

Wow, I can’t believe it. All my research and no one else mentioned it having 2 5volts! Thank you times a million.

You have 4 (not 2) female headers with 5V.