NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Basic Electronics » Digital Input Question
May 26, 2011 by frankdwest |
Is it possible to configure an I/O port pin so that an external +5V will be a HIGH? The examples I have seen so far configure the pins so that an external ground is a HIGH and an open circuit is LOW. This is confusing to me, I don't think I understand this. Thanks in advance |
---|---|
May 27, 2011 by Rick_S |
I think you may have gotten your high and low terminology a bit mixed up. 5v is high level no matter what. What you are seeing is not ground being HIGH but ground being used as what is known as a low level or "sink" type input. Most of the examples given use a common practice of pulling an input low by connecting it to ground to detect a button press. I believe the main reason this is done especially with the AVR micro-controllers is due to the fact they have built in pull-up resistors. This allows the end user to connect an input button with no extra circuitry. Now, if you want to detect an input when it makes a low to high transition, you can definately do that. You simply have to connect a resistor from the input pin to ground that will "pull-down" the input. Then connect your normally open (N/O) switch to 5v. This way when the switch is open, the input is low and when you press the switch, the input goes high. If you do this, you must change the code that sets up the pin you are using for an input. Mainly you DO NOT want to enable the internal pull-ups. So if you wanted to setup Port C pin 1 as an input, the common method would be this:
If you wanted to use an external pull-down resistor and read a high input you would turn off the internal pull-up and then what you read would be reveresed.
Hope that helps, Rick |
May 27, 2011 by frankdwest |
Thank you! I knew I was confused on some points on this. |
May 28, 2011 by frankdwest |
I breadboarded this and tried the code and it worked perfectly. |
Please log in to post a reply.
Did you know that a square wave sounds different than a sine wave? Learn more...
|