Getting a digitalRead from whether an LED is on

Hello, sorry if this is fairly obvious/derpy. I'm pretty new to electronics.

I'm trying to connect a chromatic tuner ( ) to an arduino, to read whether certain LEDs are on, (then react to them), in order to react to the read notes.

I'm not sure how to connect the LEDs to the pins or how to write the sketch to interpret the input and read whether an LED is on.
Basically, I'd like the on/off state of an LED to act as a switch for the HIGH/LOW digitalRead state of a digital input pin. I'm not sure how to wire or write this.

The project is similar to:

At the moment, I've just tried putting wires from the side of each LED on the tuner into arduino pins. Not having much luck.

Many Thanks.

show us the sketch

how did you connect the LEDs?

Main problem is I haven't really got any idea how its even supposed to be done.
At the moment I've got a connection from one side of an LED to a pin, pretty sure that can't be right, as surely its got to be grounded. Been experimenting grounding from other side of LED or a common ground to no avail.

Sketch currently testing is just chopped together from an old project which used switches. (Not sure if I'm even on the right track with this.)

I'm kinda floundering. Thought this was be fairly straight forward, but I just haven't the foggiest how to fit it together and can't find many examples of it being done.


#include <MIDI.h>

int C = 2;
int Csharp = 3;
int D = 4;
int Dsharp = 5;
int E = 6;
int F = 7;
int Fsharp = 8;

int OneLED = 9;
int TwoLED = 10;
int ThreeLED = 11;
int FourLED = 12;
int FiveLED = 13;

void setup(){
 pinMode(C, INPUT);  
 pinMode(Csharp, INPUT);  
 pinMode(D, INPUT);  
 pinMode(Dsharp, INPUT);  
 pinMode(E, INPUT); 
 pinMode(F, INPUT);  
 pinMode(Fsharp, INPUT); 
 pinMode(OneLED, OUTPUT);  
 pinMode(TwoLED, OUTPUT);  
 pinMode(ThreeLED, OUTPUT);  
 pinMode(FourLED, OUTPUT);
 pinMode(FiveLED, OUTPUT);
 digitalWrite(C, LOW);  
 digitalWrite(Csharp, LOW);  
 digitalWrite(D, LOW);  
 digitalWrite(Dsharp, LOW);  
 digitalWrite(E, LOW); 
 digitalWrite(F, LOW);  
 digitalWrite(Fsharp, LOW);  
   digitalWrite(OneLED, LOW);
   digitalWrite(TwoLED, LOW);
   digitalWrite(ThreeLED, LOW);
   digitalWrite(FourLED, LOW);
   digitalWrite(FiveLED, LOW);

void loop(){
   int val;
   int speed;
if (digitalRead(C) == HIGH){
    digitalWrite(OneLED, HIGH);
    digitalWrite(OneLED, LOW);
if (digitalRead(Csharp) == HIGH){
    digitalWrite(TwoLED, HIGH);
    digitalWrite(TwoLED, LOW);
if (digitalRead(D) == HIGH){
    digitalWrite(ThreeLED, HIGH);
    digitalWrite(ThreeLED, LOW);
if (digitalRead(Dsharp) == HIGH){
    digitalWrite(FourLED, HIGH);
    digitalWrite(FourLED, LOW);
if (digitalRead(E) == HIGH){
    digitalWrite(FiveLED, HIGH);
    digitalWrite(FiveLED, LOW);
if (digitalRead(F) == HIGH){

if (digitalRead(Fsharp) == HIGH){

(Trying to read D1 - D7 LEDs on the from the tuner circuitboard.)

1st mistake
don't attempt to drive the LEDs directly
you really should use a resistor in series with each
smoke escapes from the Arduino at the least excuse!

2nd mistake
if you want to measure the voltages off that board that's dangling, you need something connected to ground!

1st mistake
don't attempt to drive the LEDs directly

Aye, I know. Just a v quick test trying to get some life out of it. Bad habit.

2nd mistake
if you want to measure the voltages off that board that's dangling, you need something connected to ground!

Yup. This is what I've been testing. Just not sure how to connect things up. As I've said I've tried grounding from other side of LEDs and connecting the board to a common ground to no avail.

you need a ground from the ground of the dangly board to ground on the 'duino

I guess a more fundamental question is why would you need to read back the state of the leds when it's your own sketch that is turning them on or off?

Normally one would just set variables to reflect the last value you sent to each digital output pin, and then you could just use those variables to determine if the present state of a led is on or off. Or you could just do digital reads on the output pins to determine the state they are at as you seem to be doing in your posted sketch. But first of course get some resistors wired in series to those LEDs, no excuses allowed.


Wow! You're really trying to burn out as many pins as you can on your Arduino at once, I see!

First step remove -everything- you have connected to your Arduino. I'd say pitch the Arduino and get a new one, because who knows how well it works now (at least get a new DIP ATMega chip with a bootloader).

Anyhow - once you have everything removed, write some ultra-simple code to take an input on any pin (except pin 13!) and then turn HIGH/LOW pin 13 (you know, the one with the nice built-in LED - the one you -aren't- using in the picture!) - based on that input; something like:

void setup() {
  pinMode(9, INPUT);
  pinMode(13, OUTPUT);
void loop() {
  digitalWrite(13, digitalRead(9));

Now look at your chromatic tuner board - notice the signs on the PCB silkscreen of "+" and "-" (white lettering, in circles)? My best guess are those indicate positive and negative power supply planes from the battery that powers the tuner. The best way to verify this is to measure the resistance (using your multi-meter - you do own one, right?) from the battery connector's negative connection to a connection on the "-" plane; it should be zero ohms. Do the same with the positive connection to the positive plane.

First, remove the battery from the tuner.

The best points of measurement for the positive plane would be on the "flat" and "on/off" buttons - notice the gold plated interlocking "combs" that form the button surface? The one that is shaped like an "E" (backwards "E" based on the perspective of the picture) looks to be connected to the positive plane of the board. Do your resistance check between that point and the battery's positive connection.

For the negative connection - that is more difficult to tell from your picture (not quite taken with a potato, but close); my best guess so far is that third pin from the left on the black plastic connector in your picture (the one conspicuously unconnected!). Check that first; otherwise, you'll have to locate a ground pin elsewhere. But there likely has to be one on that connector, so ohming out the connector to the battery ground is your easiest/best option. I'm pretty certain pin 3 is the ground connection, though.

BTW - you haven't said what the voltage of the tuner is; all I see is a 3V button cell in the picture - so maybe it is a 3V system - if not (perhaps it uses multiple cells in series?) then you may want to stop what you are doing HERE, and let us know. You might also want to find out what the voltage is at the pins to the LEDs (measure the voltage from the pin to ground, when the LED is supposed to be "on"); to register a "HIGH" on the Arduino, the voltage will need to be somewhere around 3-5 volts.

So - assuming the LED output when it is on is only 3-5 volts - take a wire from -only- D1 (well, the pin for it from the connector) and run it to pin 9 on the Arduino, and take your ground from the PCB (if it is that Pin 3) and run it to the GND pin on the Arduino.

Start the Arduino and put the battery back in the board, and try to activate D1. If you get the pin 13 LED on the Arduino to light, then you have success.

In short - your code and your wiring job (including all the mistakes) are an example of trying to do too much at one time, instead of breaking the problem up into smaller steps and tackling each one in succession in order to achieve an overall final goal. You need to start simple, and work your way up. Yes, it's boring. Yes, it's tedious.

But it works.

Too much guessing is going on here. First things first. Get a voltmeter and measure the voltage on both side of the tuner LEDs both on and off. Even voltages from a fast blinking led will tell us what we need to know.