Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Ustary on February 18, 2011, 02:52:23 PM

Title: Arduino digital read
Post by: Ustary on February 18, 2011, 02:52:23 PM
Hi. For my robot i need some contact switches working with an arduino. The switches are copper and alluminuim, and work pretty well, with barely any resistance at all. on the parts that shouldn't conduct, i use ductape. The problem is, sometimes the digitalred of my arduino returns 1 instead of 0 even if the contacts are seperated by ductape. Can someone help me solve this? these contacts are a vital part of my robot...

Thank you
Title: Re: Arduino digital read
Post by: waltr on February 18, 2011, 03:05:47 PM
Do you have a pull-down resister on the input pin to ensure that the logic level is 0 when the switch is open?
Title: Re: Arduino digital read
Post by: Ustary on February 19, 2011, 02:10:35 PM
No, there is no said resistor. How would i go about doing this?

Thank you
Title: Re: Arduino digital read
Post by: blackbeard on February 19, 2011, 02:43:58 PM
No, there is no said resistor. How would i go about doing this?

Thank you

the resistor is there so that a logic level of 0 or 1 is always maintained. digital logic becomes unstable (hence the erroneous 1s) when pins arn't tied down to one or the other. if your switch ties the pin to ground lets say then the resistor (2.2k should work) would go to +5v
Title: Re: Arduino digital read
Post by: Ustary on February 19, 2011, 02:58:58 PM
Thank you for the reply. I'll try to get some resistors, and experiment with them.