(Solved)Some general questions(might be very simple)

Hello everyone, I hope your all fine. I am building a new project and I am encountering some problems. Some of my questions might be very simple and easy to answer but I have difficulties searching for 100% correct answers on web(it might be cause of my bad english).

  1. I want to add four HCSR04 sensors to the project, so I need to know what conditions must be met the trigger and echo pins. For example does any needs pwm? Can I connect them in both analog or digital pins? Can I normally use the A6 and A7 pins of arduino nano?

  2. I designed the project using an arduino nano, and then i decided to make it using a barebone arduino using the ATmega328 but realized that the microcontroller has only 5 analog pins(which means I run out of pins) and i got very confused. Is there any trick getting those 2 analog pins without multiplexers?

  3. Which multiplexer(I am not sure if I am correct) should I use to add more HCSR04 sensors?

  4. When is it possible to use the TX-RX(D0-D1) pins?

Thanks everyone for your time, really apreciating any help.

They don't need PWM, You cannot use A6 or A7

You can use pin 0 and 1 if you're not using aerial for anything else.

I don't understand most of the rest.

AWOL: They don't need PWM, You cannot use A6 or A7

You can use pin 0 and 1 if you're not using aerial for anything else.

I don't understand most of the rest.

So what's special with those two analog pins?

  1. How the arduino nano has 7 analog pins? It is using the Atmega328 which has only 5 analog pins.

  2. I have seen some people using some chips to get more digital-analog I/O. I think they call them multiplexers. I have never used any so I am asking if anyone knows which should I use to add the HCSR04 sensors as I need more pins than the ATmega328 allready has.

I hope this time I am more clear.

So what’s special with those two analog pins?

That’s all they are - inputs to the analogue mix.

  1. How the arduino nano has 7 analog pins?

I count eight.

ATMega328 has 8 analog input pins, A0 - A7 but only 6 (A0 - A5, port C0 - C5) can be used as analog OR digital (pins 14 - 19), Nano brings out the other 2 (A6,A7), but they are analog only, connected directly to the analog multiplexer and not through port C pins. You need 2 DIGITAL pins for each HCSR04, besides Vcc & GND pins.

akiskaps: 2. I designed the project using an arduino nano, and then i decided to make it using a barebone arduino using the ATmega328 but realized that the microcontroller has only 5 analog pins (which means I run out of pins) and i got very confused. Is there any trick getting those 2 analog pins without multiplexers?

The trick is to use ATmega328P in the 32 TQFP or 32 MLF packages (like the Nano) instead of the 28-pin DIP package (like the UNO). The packages have four more pins, of which two were used to add two more inputs to the analog input multiplexer (A6 and A7).

akiskaps: 3. Which multiplexer(I am not sure if I am correct) should I use to add more HCSR04 sensors?

A 74HC153 multiplexer should allow you to connect the Echo pins from four modules to a single input pin. It needs two address outputs.

A 74HC155 demultiplexer should allow you to connect a single output pin to the Trigger pins of four modules. It also needs two address outputs BUT they can be the same two pins as the multiplexer.

That's four HC-SR04 modules with four pins instead of eight. You can add one address pin and use 8:1 demultiplexers (74HC138) and multiplexers (74HC151) to use eight modules on five pins.

akiskaps: 4. When is it possible to use the TX-RX(D0-D1) pins?

When you aren't using Serial you can use those pins for digital I/O. If you use the Arduino Pro Mini (which has no USB port) you don't have to worry about the USB chip trying to drive the RX pin while you are trying to use it an an input or output.

Allright! Thanks for the information was really helpfull