Pages: [1]   Go Down
Author Topic: Help with using Arduino Uno i/o pins as both input and output  (Read 367 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The short version: suggest a small relay or transistor (Preferably transistor) that I can turn eight of on with a single output pin on the arduino.

The long version:
I have looked for a way to do this, but I have not really come up with a good way to word my search. If there is a simple way for me to look, or a simple solution please tell me and this topic will be removed.

The "problem" is that I would like to use the pins (2-9 specifically, not that it matters that much) as an output, and an input within the same sketch. My code is fine, but I need help with the design of the hardware. I would like a way to have the pins 2 through 9 to have led's connected to them, but also to be able to detect input (not at the same time) I planned on using transistors as switches for the led's so that the led circuit would not effect the outcome of the digitalRead(and get a false HIGH) but because I have eight of them, the remaining pins 11, 12, and 13 were not strong enough to open the transistors wide enough to keep the LED's bright. Is there any transistors that I could drive 8 of with one pin. If not is there any that I could drive 3 of. I would like to keep the whole thing powered by the arduino(with usb), with no relays. If I do get new transistors, how should I wire them. I currently have all of the base pins and the collector pins wired together (not base to ground, but ground to ground, and base to base but i assume that you knew that) and then each of the collectors this is likely where my problem is, but I can not think of another way to do It. I am not looking right now (I am home for Winter break, and I switch between my parents houses) but I think that the collector line is wired to ground, and the base is to pin 13. The emitter goes through the led, and then to the output pin. Unless I have forgotten something very important(which is probably true) that is the only way to wire it, and get the leds to light when I need.
I could use relays if need be, but I would prefer not to. If i do end up needing to use relays, I would like a suggestion of small ones that are fairly cheap. I would also need to know how to run all of them off of a single (or three) pins on the arduino. I assume that if I just wired them in series that they would all get activated, but I am not sure.

Thanks in advance for any help.

Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 505
Posts: 31337
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is hard from your description to know what you have done. Things like
Quote
because I have eight of them, the remaining pins 11, 12, and 13 were not strong enough to open the transistors wide enough to keep the LED's bright.
Do not make any sense and are wrong thinking.
It is difficult to use a pin as an input and an output without the input function affecting the output.
Exactly what are you trying to do?
Logged

Global Moderator
Boston area, metrowest
Online Online
Brattain Member
*****
Karma: 435
Posts: 23601
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a shift register controlled by pins 11-12-13, TPIC6B595, lot of sink current. Other versions of TPIC6x595 can do other current levels.
Or any shift register that can drive transistors.

The 8 pins, connect pin to resistor to LED anode, cathode to Gnd. Connect normally open swith across the LED.
In code, alternately change the pinMode of the pins - when an output, a High will light the LED, and Low turn it off; when an input with pullup resistor enabled, the input will be high when the switch is open and low when the switch is closed.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Phillipsburg, NJ
Offline Offline
Full Member
***
Karma: 6
Posts: 174
Author: Matrix Keypad Library
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The "problem" is that I would like to use the pins (2-9 specifically, not that it matters that much) as an output, and an input within the same sketch.
It's time for bed so just a quick note to let you know that the technique you are talking about is called multiplexing.  Try searching on multiplexing LEDs with Arduino.
Logged

Pages: [1]   Go Up
Jump to: