Basic Electronics Questions - Toggling I/O

This is a pretty easy question, but I always get confused about pull ups and pull downs and stuff...

Imagine a simple ring-in "game buzzer" type setup (it's a close as I can describe it). Of course if I set a pin to input and put a switch on it and set another pin to output and put an LED on it, then I can check the state of the switch and turn the LED on and handle lock-out and stuff with code.

If you have more players than you have pins, you could use mux/demux and other digital logic. I understand that and those chips are cheap, but that isn't my question either ::slight_smile:

What if you wanted to have each pin handle the input and output, how would you wire it up and code it so that the loop() function scanned the pins set to input and when a button is pressed connected to an input pin, that pin could be set to output and light an LED on that pin (no other inputs would be considered until a reset button was pressed)?

Consider a simple case using two pins and a minimum number of components (pushbutton switch, LED, current limiting resistor). Can that be done? Can you connect a reverse biased LED in parallel with the switch or something?

This can be done. I remember seeing a basic stamp (original) circuit that used the seven pins as digital i/o for an lcd (4BIT WITH 3 CONTROLS) and a 4x4 matrix keypad for input on the four data lines. The key is that there are actually three states on most micro controller lines (High, Low, and HighZ (floating)).

The following link describes an example of how this works:

http://www.parallax.com/dl/appnt/stamps/bs1Appnotes.pdf

Yeah, I think that is what I was looking for. Thanks! I'll scratch my head over it a bit and give it a try on my Arduino.

Does this involve any of those tricks like reading inputs from output pins or whatever that is where you are engaging and disengaging the internal pull up/down resistors?

I think you could do it that way. But the parallax example uses external resistors. I would recommend that approach-if you accidentally disabled the pull-up resisters in the wrong configuration you could subject the io pin to excessive current.