I'm starting a MIDI controller project that will have 8 buttons. I plan on having 8 leds to activate when the button is in its on state.
Question: Do the leds need a resistor on them?
Thanks, and yes, I'm a total newb.
I'm starting a MIDI controller project that will have 8 buttons. I plan on having 8 leds to activate when the button is in its on state.
Question: Do the leds need a resistor on them?
Thanks, and yes, I'm a total newb.
Yes, LEDs always need a resistor when driven from an Arduino pin or a shift register pin.
Yes, all LEDs need a resistor to limit the current to maximum of 20mA, otherwise they will have a very bright, yet short life. There's a ton of online tools to calculate the resistance needed, like this one: http://led.linear1.org/1led.wiz
By the way, check out my Instructable on how to build a MIDI controller. I'm just about to update the software to work with the Arduino IDE 1.6.x.
It depends if you use buttons and LEDs separately or not.
There are buttons available which have built-in LEDs and those normally come already with built-in resistors.
I use some of those buttons in my projects. Normally those "LED-powered" (Angel-eye) buttons are set for 12V or even 24V (industrial environment). My experience is, when I use the 12V types they are quite visible when lit even with only 5V.
Here is an example of those metal buttons.
or these
Meanwhile 5V types are available, but they seem to draw much current and you might have to use a transistor to help powering them with your Arduino.
Just double checking: I'm using an Arduino Micro. So I still need the resistors, yes?
Do some boards have resistors built into them?
Since I have an Arduino Micro board, and the specs say 20 I/O pins, will I have enough room on it to connect 8 buttons and 8 LED lights? Or does each one require two of the pins?
Thanks
None of the official Arduino boards have built-in resistors. And yes, 20 pins is enough, LEDs or buttons only need 1 I/O pin.
Just out of curiosity: what MIDI firmware/library are you using?
will I have enough room on it to connect 8 buttons and 8 LED lights?
For this you need 16 I/O pins.
The LEDs will be connected with each of their anodes via resistors to the adequate output pins; I would connect the buttons directly to Input pins with setting internal pullup resistors in the code.
The "2nd pins" will all be wired to GND.
The press of a button will then be read as a LOW.
Thanks, PieterP! I'm trying to build the following project:
I have the main MIDI controller on the left in the pic, and am trying to follow the directions for the Aux Expansion pedal on the right. The only modification is that I want to add an LED to each button, so I know which one is active on stage. I'm actually just a musician with no electronic DIY experience.
There's a link to the code that the mfg is supplying in the blog. I've asked them to help me modify the code to include the 8 LEDs, but no luck yet. I think I might be able to figure it out, though.
Interested to know what you think.
pusher
rpt007:
For this you need 16 I/O pins.The LEDs will be connected with each of their anodes via resistors to the adequate output pins; I would connect the buttons directly to Input pins with setting internal pullup resistors in the code.
The "2nd pins" will all be wired to GND.
The press of a button will then be read as a LOW.
Hi RPT007,
I was wondering about needing more than just the 16 pins. There's also a MIDI jack to hook in, a 9VDC jack, as listed here:http://www.morningstarfx.com/#!Building-your-own-Arduinobased-Midi-Controller/cdcj/5771e48b0cf2bcae6e414460
What do you think? Is the Micro adequate for this project? I just can't tell with my skill level at the moment. And it would suck if I got to the end and had to start over.
Thanks for any input you can give.
If I am not mistaken - the code you are referring to just needs your above mentioned 8 buttons, one LED on pin12 and TX, RX pins (pins 1 and 2) of the Arduino.
So on a micro you will have plenty of pins free to be used for your additional 7 LEDs.
Just have a look at the datasheet of a micro and you can choose any of the "free" I/O pins to use them as digital outputs.
If I counted right, then you have a spare of (20 - (8+1+2)) = 9 I/O pins for 7 LEDs, which seems to be ok as normally 9 is greater than 7 8)
What you should keep in mind though is not exceeding the overall current draw of your application.
Without the help of external transistors your Arduino is limited to 40mA / I/O pin and the total current must not exceed 200mA.
Modern LEDs are really bright sourcing them with 5mA each, so make sure you select those bright/low current ones. If the LED's are not lightened simultaneously you could draw more current per pin. Don't forget to add resistors in series with the anodes of each LED.
If you need help with the calculation of the resistor value, let us know.
Interesting project! The way I understand it, there's 6 buttons to select presets, and 2 buttons to switch between 30 banks of presets. This would mean that you only need 6 LEDs. However, if you wish to, you could make it 8 presets, and just leave the banks as they are. In theory, with this configuration, you could go as high as 20 buttons and 20 LEDs, since you can use an easy hack and some clever coding to connect the switch and their LED to the same pin, leaving 1 pin for the MIDI output.
Thanks, gents (I'm assuming),
It's a cool project and I'm just blindly diving into it. This company has an online editor that will allow me to assign any button to do anything once it's hooked up. I plan to make all 8 buttons preset selectors, and I'll use the 6 on the MIDI controller for banking up and down, and tap tempo, leaving 3 more buttons for presets.
RPT007, that is invaluable help. I've purchased two different sets of resistors for the LEDs. 4.7K ohms and 6.2K ohms. I'll see which one is less blinding on stage. Only one LED should be on at any given time, so the power draw won't be too bad, correct?
I ordered these: http://www.newark.com/Search?catalogId=15003&langId=-1&storeId=10194&categoryName=All%20Categories&selectedCategoryId=&gs=true&st=HLMP-4700
One of the problems is that I don't understand the data sheet yet. I see the tx/rx pins, vin and gnds, and I think I get that the +5v connects to the MIDI jack. Which pins do I use for the buttons and LEDs? I just have to find plain english legend for the schematics I'm looking at.
LEDs - 1 side gets a resistor and goes to an i/o pin. The other goes to gnd?
Buttons - 1 lug gets an i/o pin and 1 goes to gnd.
MIDI switch
Pin 4 goes to 220 ohm resistor and then to +5v
Pin 5 goes to tx
Pin 2 - rx?
9v jack + goes to vin
And that's the extent of my understanding so far.
Almost right: pin 2 of the 5 pin DIN goes to ground. The RX pin of the Arduino is not used, because it's only sending data, not receiving.
And you could indeed connect the LEDs that way, or you could connect them to the same pin as the buttons to use less I/O, as mentioned above.
Got it, many thanks.
Just one more hint? Name some pins I could use. A01, etc? Any that I should avoid?
even analog pins (...ie: the A0, A1..etc) can be used as just plain ol' digital pins....
stay away from the RX/TX pins! ![]()
also.. do you need to do anything with the leds in the switches?
outside of the just lighting up with the button is pressed?
then they should even need to be hooked up to an I/O pin IMHO..
just get some lighted DPDT type switches..
similar to these perhaps:
(ignore the stems/caps used.. that was specifically added for the project they were to be used for, stem and switch caps to be threaded/connected form the outside of the 'housing' (tube).)

you can get a slew of different cap types that allow the leds/light to shine through..
RPT007, that is invaluable help
That's why you can't pay me - it would be too expensive ![]()
Only one LED should be on at any given time, so the power draw won't be too bad, correct?
Correct.
stay away from the RX/TX pins!
Not correct. The code tells you that this sketch uses at least the TX pin - as it is sending the Midi control information via serial.
If only one LED will be on at any given time you could go up to a pin's current limit. The LEDs you selected are really low current ones. They will definitely do, but you should test them in your stage environment, if they are ok or if you should take brighter ones.
To be on the safe side, I would stay under 20mA, if you need other LEDs.
Calculating the resistor value is pretty simple:
You have to find out in the LED datasheet:
The LEDs of the above mentioned link come with 1.7V and 2mA (don't know if that is the maximum current they ca bear or if they are already lit up very bright at that value; let's assume you want to operate them at 2mA.
Then the formula goes like this:
[(Arduino "HIGH" value) - (LED forward voltage)] / (LED current) = (Resistor value)
-> (5V - 1.7V) / 2mA = 1650 Ohm -> I would take 1.8 kOhm
If you go for other colors, the forward voltage will dramatically vary (can go up to 3.3V or so).
You ordered 4k7 and 6k2 resistors. Imho these values are too high and it might be that your LED is hardly to be seen when it is ON.
Calculation with the resistors:
Might work, depends on the "make" of the LED.
Not correct. The code tells you that this sketch uses at least the TX pin - as it is sending the Midi control information via serial.
which is exactly why I made the statement..
if being used as an I/O for the leds/buttons (as originally asked what pins to use or not use).. then he would NOT be able to control it via serial.. nor upload new sketches...etc
if being used as an I/O for the leds/buttons (as originally asked what pins to use or not use).. then he would be able to control it via serial.. nor upload new sketches...etc
-> not correct!
correct version:
if being used as an I/O for the leds/buttons (as originally asked what pins to use or not use).. then he would NOT be able to control it via serial.. nor upload new sketches...etc
pusher:
Got it, many thanks.Just one more hint? Name some pins I could use. A01, etc? Any that I should avoid?
Hi there,
That is a very interesting question because there is a catch, in fact two catches i will briefly mention here and you or someone else can look into these issues if desired.
First, and you have probably heard this one already, although the pin current for each i/o pin is rated at 40ma sink/source, the TOTAL chip current is rated at only 200ma.
That means that if you load only 5 pins with 40ma each the total will be 200ma and that would be the max, but less than 200ma is recommended because there are other things connected that will use current too. If you load 6 pins with 40ma each the total will be 240ma which exceeds the max TOTAL chip current rating. That cant be good ![]()
So the total current from all pins should be less than 200ma and leave some room for other things.
Second, and i doubt you have heard this one yet, certain analog ports (A0 through A7 on some boards) can not be used for digital i/o when certain other analog ports are being used for measuring analog voltages as with the internal ADC. Well, at least it is not recommended to do that because the fluctuating voltages on some of the analog pins used for digital i/o causes excessive noise in the other affected analog readings.
Unfortunately i cant remember which pins are affected and which ones should not be used for digital i/o when certain others are being used for analog ADC readings, but someone else here could look it up or look on the data sheets for more information.
Of course if you do not use any analog pins for reading analog voltages then this will not affect your project at all, but if you do then it is worth looking into.
No problem with the 'noob' status you mentioned earlier, i like to see new people getting involved in electronics and related like the Arduino.