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 4144 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
  • shabaz
    shabaz over 3 years ago

    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 google images):

    image


    From my perspective (others may do it differently), the way I go about it is, to decide which connections in my circuit are the simplest (e.g. basic outputs like binary status LEDs) and assign them to the least flexible GPIO pins on the chip (using the usual board pinout diagrams, or the datasheet). Then, I'll look at the board-level serial interfaces (e.g. SPI, I2C) and choose pins that support those functions, but again the least flexible ones from all other perspectives, e.g. if one set of I2C pins also supports UART, then I will likely not select those I2C pins. For buttons I'll likely try to select pins that can work as interrupt inputs, if I just have a couple of buttons or so. For encoders, again interrupt-supporting pins are important/highly useful.


    And so on, working my way through all the pins, and hopefully as a result, ending up with spare pins which have a lot of functions still available. They can go to a future expansion connector if desired. Sometimes a slight second iteration is needed when laying out the board, to simplify some track paths.


    This strategy game of selecting pins is becoming less important with some recent processors, they are more orthogonal in that selecting one pin won't shut off the option of using integrated peripherals on another pin, it's a lot more configurable basically. The Pi Pico is an example kind-of approaching that (not entirely), where there is a fair amount of flexibility, one main exception is that analog inputs are still dedicated to particular pins. 

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

    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.

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

    Ahh.. That would work too! : )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Reply
  • shabaz
    shabaz over 3 years ago in reply to Jan Cumps

    Ahh.. That would work too! : )

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Children
No Data
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