Hey all I am wanting to make a project for this HDMI 5 port switch I have. I want to be able, with an Arduino, to detect which of the 5 ports are being used (only 1 can be used at any given time).
Without buying 5 of something like this to detect current (which would be ~$30):
Would it be possible for me to just purchase one of these and hook up different resistors values to each of the 5 LEDs and use the Arduino's Analog input to detect the voltage to determine which port LED was on?
I'm thinking that the standard red led voltage is around 2.0v? And the Android analog input is 5v. If this is possible then what type of values for the resisters for each of the 5 LEDs would be best to use in order to read the difference enough for each with the Arduino's analog input?
First question: do you want to connect directly to the LEDs, as suggested by your drawing? Then you have to live with the voltage level applied to the LEDs by the switch circuitry. You also may find that the LED voltage is pulsed. This leads to the next question: what measuring tools do you have (DMM, scope)?
An alternative were photo transistors or LDRs mounted in front of the LEDs, that detect whether a LED is lighted. No risk of damaging your switch or Arduino.
Current sensing is the most complicated (and expensive) solution, without any advantage of the simpler solutions.
Finally you can wire each sensor to an Arduino digital or analog input, depending on the signals provided by the sensor. Then the Arduino can poll the inputs and determine, which one is currently active.
Why would i not just be able to attach different resistor values to each LED on the switch and read it using one analog pin and depending on the returned value know which led is on?
StealthRT:
Why would i not just be able to attach different resistor values to each LED on the switch and read it using one analog pin and depending on the returned value know which led is on?
Try and draw the circuit and you will see it all shorts out.
Have you seen the current range of that current sensor? It is not designed to detect the very small currents used for an LED.
You night be able to use simple inexpensive optical isolation chips to go between the device LED power input side and an arduino analog input pin. The input to the arduino needs individual arduino input pins, or you might use a multiplex input setup if for some reason you don't have five individual arduino input pins available (more complex)
One non-invasive method I have used is to put an LDR (Light Dependent Resistor) over each LED and cover it with opaque tape. The LDR can then be sensed with an analog input. Given the right load resistor it can even be sensed with a digital input.
For more invasive methods I think replacing the LEDs with optocouplers would be a good, reliable, and safe choice.
The very first thing you need to do and if you want help, describe here, is how the LEDs are wired in the HDMI switch.
An HDMI switch is powered by the 5V line on pin 18 from the devices connected, so it will in general be compatible with the Arduino although it would probably not be appropriate to presume it can provide enough power to operate the Arduino. You would obviously ensure the grounds are connected.
The LEDs are most likely powered via dropping resistors, so you need to find not the connections to the LEDs themselves, but the connection point on the other side of those resistors, which you can then connect through protective resistors (10k) to the Arduino inputs.
As ever, if you post questions here, you need to supply pictures (perfectly focussed, taken in bright daylight but not sun) of the assembly.
Ok how about if I used 5 4N25 chips to detect the led being on or off?
One of the LEDs would hook to Pin 1(+) and Pin 2(-). Pin 5 would house a voltage of ~3vdc from a power supply. Pin 4 would be hooked up to the arduino's Analog Pin 0.
So when the LED on the 5 port switch is powered on, it causes the ~3vdc power from the power supply to flow to the arduino where it's read as a voltage value.
You are close.
Connect opto pin 4 to Gnd.
Connect opto pin 5 to an input pin with internal pullup enabled.
When opto LED conducts, input pin will be pulled low.
If you connect an opto LED across a normal LED, the opto is going to win.
Because opto LEDs have a lower forward voltage (1.2volt).
Use a current limiting resistor in series with the anode of the opto LED.
Some experimenting with the value might be needed.
I would start with 470ohm.
Leo..
CrossRoads:
You are close.
Connect opto pin 4 to Gnd.
Connect opto pin 5 to an input pin with internal pullup enabled.
When opto LED conducts, input pin will be pulled low.
Sorry but how to i do a internal pullup enabled on a digital pin on the Arduino?
Are you talking about doing this in code:
//configure pin2 as an input and enable the internal pull-up resistor
pinMode(2, INPUT_PULLUP);