0

When passing the pin number in pinMode its possible to use A0 - A7, does it apply only to that methode? How can pinMode expect a number (is it int?) type in case of digital pin another (is it then string?) in case of analog pin? I want to use that in my class methode, is there a way to use that and have my code more readable or should I use the pin numbers? P.S. I have tried to read the source code but I don't understand the uin8_t (I know its a byte, but not how it can understand A5 as an int)

Tnx a lot

asked Nov 24, 2019 at 13:15
0

1 Answer 1

1

pinMode is actually declared as void pinMode(uint8_t, uint8_t); in arduino.h

A0 is a defined as a number (somewhere depending on the actual hardware), on an Uno/Nano it translates to 14, and when executing pinMode it translates to the appopriate bit in the correct DDRx register.

answered Nov 24, 2019 at 13:26
3
  • On an atmega328 Arduino pin 14 ( or A0 ) is directed to PORTA bit 0, which can be used as a digital I/O or alternatively as an ADC channel. Commented Nov 24, 2019 at 13:31
  • The ATmega328 doesn't have a port 0. pin 14 (A0) is PC0. Commented Nov 24, 2019 at 19:05
  • Correct: PORTC Bit 0 Thanks. In the DIP28 atmega328P-PU its Pin 23 Commented Nov 24, 2019 at 22:14

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.