1
votes

I have a project that is connecting ultrasonic sensors into Arduino Uno and the Arduino code is taking the readings from the sensors and send them to a remote server throughout ethernet shield,

Now the problem I am facing is that I need to use 6 ultrasonic sensors but when the Arduino is taking the reading from more than 4 sensors the Arduino do not function properly, but if I made the reading of the two rest sensors from pins located for one of the previous sensors it works fine, or even if I assign a default value for those two sensors it works fine,

The problem I am facing is related to the following pins: 10, 11, 12, 13 That the ethernet shield is using them but how can I overcome this problem and run all the six sensors ?

You can find part of the code below:

#include <Ethernet.h>
#include <SPI.h>
#define ECHOPIN1A1 3        // Pin to receive echo pulse 
#define TRIGPIN1A1 2        // Pin to send trigger pulse
#define ECHOPIN1A2 5        // Pin to receive echo pulse 
#define TRIGPIN1A2 4        // Pin to send trigger pulse
#define ECHOPIN1A3 7        // Pin to receive echo pulse 
#define TRIGPIN1A3 6        // Pin to send trigger pulse
#define ECHOPIN1B1 9        // Pin to receive echo pulse 
#define TRIGPIN1B1 8        // Pin to send trigger pulse
#define ECHOPIN1B2 5        // Pin to receive echo pulse 
#define TRIGPIN1B2 4        // Pin to send trigger pulse
#define ECHOPIN1B3 3        // Pin to receive echo pulse 
#define TRIGPIN1B3 2        // Pin to send trigger pulse
1

1 Answers

1
votes

You could use a board with more GPIO pins like the Arduino MEGA. Or you could connect together the trigger pins and use only one Arduino pin to drive them all.

Edit: Make sure you read Tansir's comment below and experiment to see what works and what doesn't. With the number of available pins, you would need to trigger 3 ultrasonic sensors per pin (2 pins for triggering + 6 pins for reading the echo).

There is another solution: You could use multiplexers/demultiplexers to drive up to 8 sensors with 5 pins (2 data pins and 3 address ones). This would add to the complexity of the hardware, however.