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 How to configure an Arduino GPIO as an input
  • 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 34 replies
  • Subscribers 388 subscribers
  • Views 4673 views
  • Users 0 members are here
  • arduino best practice
  • arduino circuit
Related

How to configure an Arduino GPIO as an input

colporteur
colporteur over 4 years ago

What would you recommend to reduce the spurious triggers on the input of a Nano?

 

Up to now I have been using Arduino Nano microcontrollers for animation support on a model railroad without issue. With the recent completion of the airport scene, I started to experience issues of Nano's receiving spurious triggers. At first I thought maybe I set the input resistor to high, so I reduced the value from 100K to 47K. I got some relief but it has recently raised it ugly head again. Without the resistor the triggering is unpredictable.

 

Currently there are 5 animations that have button control.

  • Aircraft landing simulation (LED)
  • Hanger building Lighting (LED)
  • Simulate arc welder at bench (LED)
  • Compound gate open/close (28BYJ-48 ULN2003 controller)
  • Hanger aircraft engine startup/shutdown (L293 brushless motor)

 

The compound gate sometimes triggers the Hanger aircraft engine animation and vise versa. The input circuit I am using for the Nano is minimal.  These two animations did share the same twisted pair from the button panel. I have separated the animations button to different pairs and I have some relief. I'm thinking maybe there is a simple way to dampen inputs so they are not as sensitive?

 

I'm hoping someone might have a suggestion/best practice recommendation for connecting inputs, that is designed to eliminate the problem.

 

image

  • Sign in to reply
  • Cancel

Top Replies

  • baldengineer
    baldengineer over 4 years ago +9
    100K and 47K are very weak pull-down (or up) resistors. If you're in a known noisy environment, you probably want something in the 1K to 4.7K range.
  • wolfgangfriedrich
    wolfgangfriedrich over 4 years ago +8
    Try a small capacitor ( 10nF ) in parallel to the resistor. This is called de-bouncing an input. Can also be done in software, there might even Arduino libraries for that. - W.
  • dougw
    dougw over 4 years ago +7
    It sounds like you are getting cross-talk as well as switch bouncing. If you put a resistor in series with the switch and a capacitor at the digital input as wolfgangfriedrich mentioned, there won't be…
  • shabaz
    shabaz over 4 years ago in reply to colporteur

    I can't recall if Cat6e is shielded or not, but in either case, at 7 feet, it's almost guaranteed to be picking up electrical noise, unless the shield (if it exists) is connected to your signal ground. In any case, it is quick to check, just put the 'scope onto the cable at the microcontroller end and see what you capture.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 4 years ago in reply to shabaz

    Thanks for the commentary. My application of an Arduino's to support animation in model railroading is all about simplicity. I'm currently conducting a workshop with a local model railroad club using video conferencing. The workshop is one workshop session each week for five weeks. The goal is to provide sufficient information for them to determine if microcontrollers are something they want to invest in for their layouts. Most participants are in their 60's with little to no technology type backgrounds.

     

    All those that attend have NO microcontroller experience. The group has managed to gain enough knowledge and comfort to successfully program the blink routine. In the next three weeks they will explore lights, motion (motors) and sound. This involves building the circuits, deploying code and then if it doesn't work determining is the problem in the physical world or the coding world.

     

    The issue with transient triggering causes me concern only because the participants have little experience with electronics and microcontrollers to troubleshoot issues. The circuits they are demo'ing are simple with minimal construction. I have to be cognitive of solutions to the problem so it can help and not hinder my target audience.

     

    Microcontrollers as logical switching devices are new to me. I fostered a career in relays and TTL controllers. I haven't seen the de-bounce issue with Pi projects so it was a surprise to me.

     

    The support has been great. Before I award the atta-boy award (Question Answered) I wanted to give the solutions a try. I like both the code and the resistor. The resistor being the simple solution.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • BigG
    BigG over 4 years ago in reply to colporteur

    I found this Arduino library to be pretty good and it's versatile: https://www.arduino.cc/reference/en/libraries/bounce2/

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 4 years ago

    I implemented BEJ baldengineer 4.7Kohm to ground resistor today. I then reconnected the two simulations to the same pair. I then went off to do something else and in short while experienced false triggers once again. Triggering the gate simulation button and the hanger simulation started up as well.

     

    I haven't implemented a bounce routine yet, I like BigG share. That will be the next test.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Cancel
  • wolfgangfriedrich
    wolfgangfriedrich over 4 years ago in reply to colporteur

    Another easy test for a simple solution would to make the 4.7k resistor a pull-up and wire the switch to GND. This gives you a higher immunity because the voltage difference from the 5V rail to a false '0' is larger than from GND to a false '1'. Assuming TTL logic would be 5V to 0.8V vs. 0V to ~2V.

    And you would need to invert your logic in the code. image

    Worth a try.

    - W.

    • Cancel
    • Vote Up +6 Vote Down
    • Sign in to reply
    • Cancel
  • neilk
    neilk over 4 years ago in reply to wolfgangfriedrich

    I've done this, but with a 10k pull up resistor. I put a 2.7 nF capacitor across the switch. Works well for me with no debouncing code.

     

     

     

    Neil

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • Jan Cumps
    Jan Cumps over 4 years ago in reply to neilk

    Wolfgang's suggestion may give some headroom. Same for the resistors.

    I'm not sure about the capacitors though. They help with bounce but not with external interferences.

    These unwanted triggering events aren't bounce artifacts.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 4 years ago in reply to wolfgangfriedrich

    Thanks WF. I have used ground trigger before on the Raspberry Pi normally. For some reason I have numerous voltage triggered Arduino's now. I can't recall when I did the switch. I really try to be consistent. I think I found an Arduino sketch that had voltage triggered in it that worked. I then started using that as a pattern.

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

    If you are into adventure, Sean, you could switch over to CAN bus.

     

    Disadvantage:

    - you'd need to have a receiver with a microcontroller at the point of action.

    - receiving nodes have to be programmed to react on messages for them.

    Advantage:

    - it's a bus. you can loop the bus wire to every place you need, usually 4 wires are enough for power and signals.

    - resilient to induced mayhem.

    - learning path isn't steep

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • colporteur
    colporteur over 4 years ago in reply to Jan Cumps

    My in my next life of helping put the foundation in for a model railroad layout I can consider the CAN bus suggestion. I installed a LAN to start because we were only supposed to be using Pi's. Arduino's filled a niche and now there is about 20 deployed and more to come. There are five Pi's running animation also.

    • 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