I have an Arduino Uno with a top-plugged SainSmart proto shield. There are 2 LEDs on the proto shield, but I don't know how to make use of these LEDs in a sketch. Are they directly controllable out-of-the-box, or do I first need to solder the LED leads to analog/digital (not sure which) outputs on the proto shield to make them accessible? And how to use the "S1" button?
4 Answers
So this is just a bare board with a few LEDs and buttons. jippie points out that series resistors are indeed included, as can be seen in the picture he linked to. (Thanks jippie.) The buttons don't have pull-up resistors so they seem to rely on the AVR's internal pull-ups for that.
A schematic of the board would help. I would find it hard to believe there wasn't one included, or at least a link to the schematic on their site. On the top side LEDs and buttons don't seem to be connected to anything, so we need to have a close look at the bottom side. Can you post a sharp picture of that?
It's unlikely that LEDs or buttons would be hard-wired to any of the I/Os, but the bottom row of the breadboarding area is possible. I marked two intriguing holes next to LED2. They're not vias, but more like the holes on the breadboarding area. They seem to suggest connections for the LED, but then where are the connections for the buttons? So I'd go back to the breadboarding area. Check if you see traces connecting to the holes on the bottom row.
Once the connections are cleared up you'll have to wire up the LEDs from +5 V to a digital output of the controller. Making that output on the Arduino low will light the LED.
The button goes between a digital input and ground. You can use the microcontroller's internal pull-up resistors, or use an external one. This goes form the input to +5 V. If the button isn't pressed the resistor pulls the input to +5 V, so you'll read a 1
. When you press the button you connect that input to ground, so that will read as a 0
. You can use a 10 kΩ for the pull-up.
-
\$\begingroup\$ There are resistors on the board already: sainsmart.com/media/catalog/product/cache/1/image/500x500/… Also I think it is important to check if the LED isn't already connected to GND or Vcc. @user10768 - do you own a multimeter? \$\endgroup\$– jippieCommented Jul 17, 2012 at 13:49
-
\$\begingroup\$ @jippie - Correct. I had only looked at the bottom side, thinking it was the top. I'm not familiar with Arduino and its connectors. You'll have to agree that a schematic wouldn't hurt, though. \$\endgroup\$– stevenvhCommented Jul 17, 2012 at 14:12
-
\$\begingroup\$ @stevenvh - yup, I was looking for a drawing too but couldn't find any either. \$\endgroup\$– jippieCommented Jul 17, 2012 at 14:21
-
\$\begingroup\$ For anyone curious there is a nice pinout / schematic of the board here (the chinesium version): geeetech.com/Documents/… \$\endgroup\$– EJTHCommented Feb 15, 2018 at 17:50
From studying the Adafruit version of this prototyping board (https://cdn-learn.adafruit.com/downloads/pdf/adafruit-proto-shield-arduino.pdf) (the PDF is for the v.6), it appears the LEDs are NOT hardwired to any of the pins (which is surprising - I would have thought LED1 might have been hardwired to Digital Pin 13, the way it is on the board itself).
So you'll need to either do a quick point solder from the (+) through-hole next to LED1 using solid core wire (22 gauge works well), stripping the other end of the wire long enough to push into any of the digital out headers, or you can use solderless jumper wires in a pinch - for quick testing.
As others have mentioned, both LEDs are already connected to ground via an appropriate resistor, so you don't have to worry about that.
Here's a really crappy photo I took showing LED1 connected to digital pin 13 using a solderless jumper wire for the ubiquitous "blink test" sketch.
(Here's the code in case you're really just starting out and just want to see something WORK!)
#define LED_PIN 13
void setup() {
// put your setup code here, to run once:
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(LED_PIN, HIGH);
delay(2000);
digitalWrite(LED_PIN, LOW);
delay(500);
}
The left one of two holes indicated at the picture is connected to the LED through the resistor. The other side of the LED is connected to GND. The right hole is connected to the pushbutton. At the other LED, there is another similar hole.
20mA for a 20,000mcd 5mm LED will be a blinding indicator so 2mA may be better. If using a 200mcd indicator 20mA may be needed. 10% of rated current is acceptable for dimming , saving power and used as indicators with HB or high bright LEDs that are very efficient transparent chips that also reflect off the back of the chip via a reflector cup and get focused to any standard angle from 10, 20 30 45 ... 90.. 180 deg
http://www.quickar.com/noqbestledcalc.htm consider most Red/Yellow as 1.6V drop and White/Blue as 3.2V drop from your supply and the series resistor as the current limiting part. That site helps calculate for you.
Your circuit looks like this... except runs on 5V.. so R series is lower. YOu might also consider 1KΩ if too bright.
for Red 5-1.6V=> 3.4V / 1KΩ = 3.4 mA or 17% of max brightness @ 20mA
-
12\$\begingroup\$ OP is clearly a beginner. Why don't you help him being more novice friendly and take those mcd, mm and other stuff that makes no sense to a beginner that haven't even lit an LED? \$\endgroup\$ Commented Jul 16, 2012 at 18:04
-
\$\begingroup\$ I said 20 mA is typical for an indicator LED. A 20 000 mcd is not a typical indicator LED. \$\endgroup\$– stevenvhCommented Jul 16, 2012 at 18:08
-
\$\begingroup\$ stevenh you also said the link I posted was incorrect on Kirchoff's Law Please try again . it is correct for inputs given, I assert your assumptions were wrong for Vf. 1.6V 20ma 5V = 180ohms Besides you do not need 20mA for a small indicator. They certainly do not use that on keyboards, Phones or other standard user interfaces unless you are using 20yr old LEDs. It accurately calculates your assumptions. Abdullah I do not wish to insult anyone's intelligence nor any newbie's , Kirchoff's Law and a site that calculates it accurately for you.. forgive me if it is wrong and maybe steven is wrong \$\endgroup\$– D.A.S.Commented Jul 16, 2012 at 20:58
-
\$\begingroup\$ I agree stevenh on 20000 mcd not typical for cheap projects for designers who serve Industrial market; CMS signs, roadsigns, Sony blue Playstation LEDs, 20 Cd is pretty typical.. it all depends on your experience, exposure and know where to look. Consumers can get close that at Digikey . Commercial buyers hate to pay more than a dime for indicators. maybe 20 cents in a large project. e.g. consumer 5mm 20mA indicator in Red digikey.com/product-detail/en/HLMP-EG1A-Z10DD/516-2457-3-ND/… expect more in White. \$\endgroup\$– D.A.S.Commented Jul 16, 2012 at 21:29
-
1\$\begingroup\$ I checked on Digikey and just over 2/3 of their LEDs are rated at 20 mA. It's possible that Digikey is behind on this, but I don't think so. \$\endgroup\$– stevenvhCommented Jul 17, 2012 at 10:10