Arduino Mega – Blinking a LED

In this tutorial I am going to show you how to blink a LED using Arduino Mega 2560. You can use any Arduino Board.
If you don’t have the optional parts written in below, you can do this tutorial without them.

Parts Required

  • Arduino Mega 2560;
  • Breadboard (optional);
  • 1x LED (optional);
  • 1x 330 ohm or 220 ohm resistor (optional);
  • Jumper wires (optional).

This tutorial uses a LED attached to an Arduino digital pin. I use pin 7 to connect LED, but you can use any of the digital pins.

Building the Circuit and Schematic

In case you have the LED, the resistor and breadboard you can connect all together following the schematic bellow. Here we are using “D7” pin from Arduino Mega.
If you don’t have this parts, so you can also use the built-in LED of the Arduino board, that in this case is connected internally to the “D13” pin.

Code

Step 1: Start from open Arduino IDE. If you don´t have it installed yet you can download the last version from here: https://www.arduino.cc/en/Main/Donate

Step 2: Select your board on “Tools -> Board -> Board Manager…”.

Step 3: Select your COM Port “Tools -> Port->…”.

Step 4: Then copy the code bellow to your Arduino IDE project and save it. In case you don´t have a LED you can use the built-in LED from the Arduino development board, just comments the first line of the code bellow, inserting “//” before “#” and replaces LED with LED_BUILTIN throughout the code;

Step 5: Connect your Arduino to your PC using micro-usb to usb cable and upload the code, pressing upload button.

If you upload the code without errors, the LED blink every half a second.

João Louro

Author: João Louro

Electrical Engineer with special interest in Embedded Systems, Real Time Operating Systems and Audio. With a degree in Electrical and Computer Engineering in the field of Electronics and Computers and currently studying Master's degree in Electrical Engineering.

1 thought on “Arduino Mega – Blinking a LED

  1. Nice post. I be taught something more challenging on totally different blogs everyday. It would all the time be stimulating to learn content material from other writers and apply a little one thing from their store. I’d prefer to use some with the content material on my weblog whether you don’t mind. Natually I’ll provide you with a hyperlink on your web blog. Thanks for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *