Getting started with Arduino Mega

I just received my Arduino Mega, and got the simple programs that flash the onboard LED going right away. Now I'm trying to flash an LED that I put on an external breadboard. I put a 1K resistor between the LED and the Aduino's ground, and connected the + side of the LED to pin 8 and changed the program to use pin 8. Nothing happens. I've confirmed that I can light that LED by supplying anywhere from 1.5 to 6 volts to it directly on the breadboard. Any ideas what I'm doing wrong? I'm a professional Java programmer, but a newbie with electronics. Thanks.

Did you remember to set the pinMode for pin 8 to an output?

Yes. I set the pin variable to 8, and part of the program I'm using sets the pin referenced in that variable to output. FYI, I'm using the "Making Things Talk" book for my initial work with the Arduino.

There are several pins labeled "gnd" on the board. Any of those should work, right? I've also tried this with pins other than 8, and none of them works either.

All the Gnd pins are connected together - you can use any one you want.

Try the sketch that blinks the led on pin 13. Connect your external led as described in your earlier post using the 1k resistor, but use pin 13 instead of 8 and see it that gets both LEDs blinking

When I do that, the onboard LED blinks, but not the external one. The code I'm running is as follows:

int LEDPin8 = 8; int LEDPin13 = 13;

void setup() { pinMode( LEDPin8, OUTPUT ); pinMode( LEDPin13, OUTPUT ); }

void loop() { digitalWrite( LEDPin8, HIGH ); digitalWrite( LEDPin13, HIGH ); delay( 1000 ); digitalWrite( LEDPin8, LOW ); digitalWrite( LEDPin13, LOW ); delay( 1000 ); }

Code looks ok, that leaves seeing what the external wiring actually looks like. Is the LED wired in the correct direction (they are a polarity sensitive component) ?

Lefty

The short leg is wired to ground, long to pin 8. When I tested it with external power, I had the short leg wired to ground and the long leg to + (tried several different voltages, all of which lit the LED).

Should I be able to read 5 volts between ground and pin 8? My meter is showing me a constant 0.16 volts.

The short leg is wired to ground, long to pin 8. When I tested it with external power, I had the short leg wired to ground and the long leg to + (tried several different voltages, all of which lit the LED).

Should I be able to read 5 volts between ground and pin 8? My meter is showing me a constant 0.16 volts.

When you tested it by directly connecting it to several different voltages did you still use a series resistor? It not then maybe too much current flowed through the LED damaging it. Current must be limited to a LED at all times. You should be able to read 5vdc on pin 8 to ground if the pin is programmed as a output pin and set to high.

Lefty

Yes, I always used the resistor. Also, at several points in the process I also retested the LED by providing it with external voltage while disconnected from the Arduino, and it has lit up every time.

Have you ever heard of defective Arduino boards? That's what I'm starting to suspect.

Did you try connecting the LED to pin 13 as suggested in reply#3 above (both internal and external LED on the same pin). If the internal LED blinks but the external one doesn't then the board is probably ok.

Yes, and the internal LED continues to blink while the external one does not. I don't understand how that indicates that the board is good. I'm wondering whether the connections between the pins on the chip and the connectors along the sides of the board are bad. I looked up the pin diagram for the chip, but I'm not able to figure out which pin corresponds to the numbered pins along the board edges. If I could identify the correct chip pin for a given board pin, I could check for continuity between the two.

if you have a multi-meter you should be able to see the voltage change from 0 volts to 5 volts on pin 13 when running the blink sketch. If that is what you see, then the board is probably OK.

BTW, Pin 13 is connected to the ATmega 1280 chip pin 26 and R1 (the 1k resistor that connects to the LED on pin 13)

Got it working. A friend noticed that there are duplicate pin numbers on the board. I had the LED connected to the pins for analog in rather than the identically numbered PWM pins.

Thanks for all the suggestions.