1

I got a copy of Arduino from a local retailer here (it's a local copy and I'm pretty confused with how the pins actually work).

I know basic electronics so far, there should be two pins for every node one acting as the negative terminal and other as the positive terminal. If I were to connect an LED with my Arduino board which pins would I be utilizing?

Here let me tell you how pins are arranged on mine:

IOREF                                                                         GND                                  

                                         13  
RESET                                                                         12  
3.3V     //this left group marked power                                        .
5V                                  //right group marked PWM                   2
GND            //right groupmarked communication                          TX0 -1  
GND                                                                       RX0- 0                                   


V1N                                                                       TX3-14       
                                                                         RX2 -15
A0                                                                         ..
A1                                                                      SCL -21
..   //THIS left GROUP MARKED ANALOG IN
A7


A8
A9 //I believe it is part of the above group
..
A14
A15

     //the pins below marked DIGITAL
     52-50-`48-46...........................................................22`
4

there should be two pins for every node one acting as the negative terminal and other as the positive terminal.

No, there is one pin per node, and a common "Ground" pin which is the negative terminal. On your Mega2560 are 5 ground pins (effectively equivalent because they are connected). They are circled on the photo below, and marked GND on the board.

Mega2560 board


As Majenko says in his answer you must use a resistor in series with any LED you connect, or you will damage both the LED and the processor.

You may find a "breadboard" handy for making connections, most prototyping boards have a long connected strip for sharing the Ground wire between different places, like this:

Prototyping board

The continuous blue lines indicate pins which are connected together (for Ground) and the continuous red lines are connected together for +5 V (usually).


Btw can you tell me why there are two pins on the bottom horizontal row?

Just for convenience. You often want an extra ground pin, for example if you are trying to connect up two LEDs.

Secondly, yes each pin can be set as input or output but is there any specific difference in the type of pins?

Some of the pins can optionally be used for extra hardware-supported features.

  • PWM: Pulse-width-modulated output
  • COMMUNICATION: Serial input/output (4 serial ports)
  • ANALOG IN: Analog-to-digital converter (ADC) input
  • DIGITAL: Digital (not analog) input/output
  • SDA/SCL: I2C communications
  • Pins 50-53: SPI communications (not marked on the board)

However all pins, as you noted, can - if you wish - be used for digital input or output.

  • Great. Thank you. Btw can you tell me why there are two pins on the bottom horizontal row? I mean the grounds on left and right are singled pin but on the horizontal row they are double pinned? Secondly, yes each pin can be set as input or output but is there any specific difference in the type of pins? If yes, what? If not, why are they categorized as PWM, COMMUNICATION,ANALOGI IN,and DIGITAL? – Robino Collaso Aug 16 '15 at 4:09
  • This is another example of a lengthy answer, which doesn't get a single upvote, nor an accepted answer vote. So it is recycled by "Community" as unanswered. IMHO it was answered. – Nick Gammon Jan 13 '16 at 10:29
  • One good turn deserves another. – Majenko Jan 13 '16 at 11:07
3

Any IO pin can be set to either be an input, where it reports to your program if the voltage present on that pin (relative to ground) is above or below a certain threshold (HIGH or LOW voltage), or it can be an output, where it can either be set to be a HIGH output (pin is connected internally to +5V) or a LOW output (pin is connected internally to GND).

To drive an LED you would connect one side of a small resistor (say 470Ω) to any IO pin you choose. The other side of the resistor would connect to the anode of the LED. The cathode of the LED would then connect to ground. When you set the IO pin to HIGH it will provide 5V to the LED through the resistor (which is needed to limit the current as the LED is a non-linear, current driven, component) and the circuit is completed by the return path through ground.

enter image description here

Note that you must not exceed 40mA going into or out of any IO pin, and you should not exceed 25mA going into or out of any IO pin. The total current going into or out of all IO pins must not exceed 200mA.

  • Understood. Thanks, for the part where you said a resistor must be used with an LED can you tell me which formula do you use to calculate the required resistance? I=V/R R=V/I R=RequiredVoltage/RequiredCurrent Is this it? – Robino Collaso Aug 16 '15 at 4:14
  • I'm upvoting this answer to stop this question staying as unanswered. Even though I posted my own answer. :) – Nick Gammon Jan 13 '16 at 10:30
  • @NickGammon I have noticed the Arduino community is much less inclined to upvote or accept answers than other communities. Just looking at the question list you see much lower numbers in general here than in for example the Photography community. – Wirewrap Jan 13 '16 at 18:42
  • I've noticed that too. My fairly minor contributions to other SE sites (eg. English) get quite a few votes, even for a short post, but a lengthy one here, complete with schematics, photos, code, etc. can get completely ignored. It is a little off-putting. – Nick Gammon Jan 13 '16 at 20:35
  • "The total current going into or out of all IO pins must not exceed 200mA." For a '2560, the total is actually 800mA. 200mA per VCC/Gnd pin, the Mega has 4 of each. This was confirmed with Atmel tech support some number of years ago and posted at Arduino.cc – CrossRoads Sep 27 '18 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.