element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Best practices for Arduino I/O selection
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 19 replies
  • Subscribers 388 subscribers
  • Views 4140 views
  • Users 0 members are here
  • arduino_development_environment
  • arduino
Related

Best practices for Arduino I/O selection

colporteur
colporteur over 3 years ago

I'm currently working on a project using an Arduino knock-off Mega board. I discovered during prototype board development and testing an issue using I/O' 0 and 1. I found I could not control the output within my script. From online research, I discovered if I was using serial communication then I should avoid using those two I/O's. I wonder what other gotcha's don't know about?

I confess I am way down the scale of Arduinos knowledge. I label myself more of a resurrectionist rather than a programmer. I adapt code and solutions I find to solve my problems. Rarely if ever, have I built from scratch. This leads me to the title line "Best Practices for Arduino I/O selection". Are there any resources that provide this type of guidance? Are there I/O's to avoid and others that are better for a specific function?

I realize some I/O's are for specific purposes. I'm just thinking are there best practices using I/O's. I read the review posted on the site of this new book and thought maybe that has some suggestions. I'm looking for member experience.

  • Sign in to reply
  • Cancel

Top Replies

  • Jan Cumps
    Jan Cumps over 3 years ago in reply to shabaz +7
    I use the same principles but the other way round. I first do the inflexible ones, like UART, i2c/SPI, pwm/timer , interrupt and analogue. Then sprinkle the easy ones across what's left over.
  • fmilburn
    fmilburn over 3 years ago +7
    I've been caught out with this type of problem when using the Arduino IDE with a board I'm unfamiliar with so I can relate. In your case, the pins with the labels 0 and 1 on the silkscreen will cause a…
  • shabaz
    shabaz over 3 years ago +5
    Hi Sean, The usual board pinout diagrams often indicate all functions available per pin, so they can be used for guidance, but the ultimate authority is the chip datasheet. Example snippet (found via…
Parents
  • colporteur
    colporteur over 3 years ago

    I stumbled across this reference that helped explain some of the issues I described.

    https://create.arduino.cc/projecthub/BuildItDR/can-i-use-an-arduino-uno-for-this-5f1051?f=1

    The term dedicated pin actually means something to me.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • beacon_dave
    beacon_dave over 3 years ago in reply to colporteur

    I'm not sure that 'dedicated' is quite the right word though. Each pin by default is a general purpose digital I/O pin but it can alternatively be assigned to a peripheral function. 'Dedicated' could imply that it is single use, whereas 'reserved' (for a alternative peripheral function) may be better.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • beacon_dave
    beacon_dave over 3 years ago in reply to colporteur

    I'm not sure that 'dedicated' is quite the right word though. Each pin by default is a general purpose digital I/O pin but it can alternatively be assigned to a peripheral function. 'Dedicated' could imply that it is single use, whereas 'reserved' (for a alternative peripheral function) may be better.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
Children
  • Jan Cumps
    Jan Cumps over 3 years ago in reply to beacon_dave

    TI uses the term pin multiplex. You usually set a pin's function in the PINMUX regisrters of their controllers.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • beacon_dave
    beacon_dave over 3 years ago in reply to Jan Cumps

    Similarly, Atmel call it port multiplexing.

    image

    It's pretty well covered by this application note which has extracted the relevant sections from the main datasheet and thrown in an example project at the end:

    AVR42785: I/O Multiplexing Introduction with ATmega328PB
    http://ww1.microchip.com/downloads/en/Appnotes/Atmel-42785-IO-Multiplexing-Introduction-with-ATmega328PB_ApplicationNote_AVR42785.pdf

    It's not exactly a one-line overview though and being at chip level doesn't cover the Arduino specific stuff that has been flagged up here like the USB interface being attached to the UART peripheral.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube