Hi I am new to arduino and i need the digital pins more so I taught that the push button can be placed in the analog port ,but when I search the internet I found different ans but they both says the opposite of each , so I taught that ardunio community can help me ,please
The analog pins are digital pins too. So on a Uno for example you can do digitalRead() and digitalWrite() using the Ax pin names (A0 etc) and also refer to them by the numbers above 13. (So Uno A0 is the same as calling it 14, A1 is 15 etc.)
You can also use a small module which connects to the i2c and will give you extra pins when you need them.
pcf8575
https://create.arduino.cc/projecthub/xreef/pcf8575-i2c-16-bit-digital-input-output-expander-48a7c6
What do they say ![]()
But post #2 is to the point. Though I would not advise to use the pin numbers but the Ax names; this is for compatibility reasons with different boards (e.g. Leonardo).
Good point, I always forget that, but that's because every board I own is a Uno...
That is a real worry!
The UNO is a particularly inconvenient board format. The Nano is the "workhorse" version of the UNO, used for serious designs that have to do something rather than just play. It uses the same processor and thus code, just a different package, and also implements the final two, analog-only input ports.
It is far more practical than the UNO, usually comes without the pins soldered so you can solder the pins in to mount on a "solderless breadboard", or a terminal adaptor or as a daughter-board to your own custom PCB, or you can solder wires directly to the Nano PCB.
The UNO on the other hand comes fitted with sockets which limit you to flying leads or a matching "shield" so unless there is a shield which does exactly what you want (or you use a "prototyping shield" within its limitations), construction becomes messy.
One clear problem with the UNO which is primarily designed to mount "shields", is the means to connect to the sockets. Simply sticking wires in them is clearly unreliable. The proper way is to insert pin headers into the sockets, and solder to the pin headers. It is far more difficult to dislodge a whole multi-pin header than an individual wire.
Something that may be causing confusion is that some versions of the atmega328 have two additional analog ports, A6 and A7, that are not usable as digital pins. The UNO does not have these additional ports because the physical package does not have enough pins (although the ports still exist internally on the chip itself).
Another confusing thing is that analogRead() will accept either the Ax pin name, or just x, because the function only works on analog pins, but all other port functions assume x refers to a digital pin.
You can still use them as "digital" inputs for reading buttons & switches for example. I doubt you can use digitalRead() with those pins, but you can certainly use analogRead() and compare the reading with a threshold like 512. There are no internal pull-up resistors on those pins either, so you will need to add external pull-up/down resistor.
You can, of course, use them to read multiple buttons & switches connected to the same pin using combinations of resistors to give each button/switch a unique value.
Not without any digital interface! ![]()
As long as the switches do not develop leakage, as "tact" buttons tend to.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.