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?
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.
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.
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.