{"id":59,"date":"2025-02-24T15:59:08","date_gmt":"2025-02-24T15:59:08","guid":{"rendered":"https:\/\/samerli.com\/en\/lessons\/?p=59"},"modified":"2025-04-23T15:29:53","modified_gmt":"2025-04-23T15:29:53","slug":"lesson-1-simple-blinking-led-project-with-arduino","status":"publish","type":"post","link":"https:\/\/samerli.com\/en\/lessons\/?p=59","title":{"rendered":"Lesson 1: Simple Blinking LED Project With Arduino"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>In this lesson, we will learn the very basics of using Arduino by making a simple blinking LED project with Arduino.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">List of Content<\/h4>\n\n\n\n<div class=\"wp-block-aioseo-table-of-contents\"><ul><li><a href=\"#aioseo-1-needed-components\">1. Needed Components<\/a><\/li><li><a href=\"#aioseo-2-connecting-your-blinking-led-circuit\">2. Connecting Your Blinking LED Circuit<\/a><ul><li><a href=\"#aioseo-set-up-the-breadboard\">Set Up the Breadboard:<\/a><\/li><li><a href=\"#aioseo-schematics-and-pictures\">Schematics and Pictures<\/a><\/li><li><a href=\"#aioseo-alternative-connection\">Alternative connection:<\/a><\/li><\/ul><\/li><li><a href=\"#aioseo-3-code\">3. Code<\/a><ul><li><a href=\"#aioseo-how-this-code-works\">How This Code Works:<\/a><\/li><\/ul><\/li><li><a href=\"#aioseo-4-tips-for-modification\">4. Tips for Modification<\/a><\/li><li><a href=\"#aioseo-6-frequently-asked-question-faqs\">5. Frequently Asked Question (FAQs)<\/a><ul><li><a href=\"#aioseo-doesnt-the-resistor-have-to-be-before-the-led-to-protect-it\">Why does my Arduino blink pin 13 even before I upload the code<\/a><\/li><li><a href=\"#aioseo-doesnt-the-resistor-have-to-be-before-the-led-to-protect-it\">What does the resistor do?<\/a><\/li><li><a href=\"#aioseo-doesnt-the-resistor-have-to-be-before-the-led-to-protect-it\">Doesn&#x27;t the resistor have to be before the LED to protect it?<\/a><\/li><\/ul><\/li><\/ul><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-1-needed-components\">1. Needed Components<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Arduino Board<\/strong> (Arduino Uno or another type)<\/li>\n\n\n\n<li><strong>LED<\/strong> (any color)<\/li>\n\n\n\n<li><strong>Resistor<\/strong> (330 ohm)<\/li>\n\n\n\n<li><strong>Breadboard<\/strong><\/li>\n\n\n\n<li><strong>Jumper Wires<\/strong><\/li>\n\n\n\n<li><strong>Power Supply<\/strong> (USB cable or battery pack)<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-2-connecting-your-blinking-led-circuit\">2. Connecting Your Blinking LED Circuit<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-set-up-the-breadboard\">Set Up the Breadboard:<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Place the LED on the breadboard. The longer leg (anode) is the positive side, and the shorter leg (cathode) is the negative side.<\/li>\n\n\n\n<li>Connect the cathode of the LED to a digital pin on the Arduino (e.g., pin 13).<\/li>\n\n\n\n<li>Connect one leg of the 330-ohm resistor to the anode of the LED, and connect the other leg of the resistor to the ground (GND) on the Arduino.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-schematics-and-pictures\">Schematics and Pictures<\/h4>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"943\" height=\"739\" src=\"https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/20250224_185011.jpg\" alt=\"Simple Arduino schematic showing pin 13 connected to a resistor which is connected to a LED that is grounded from its cathode.\" class=\"wp-image-61\" srcset=\"https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/20250224_185011.jpg 943w, https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/20250224_185011-300x235.jpg 300w, https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/20250224_185011-768x602.jpg 768w\" sizes=\"(max-width: 943px) 100vw, 943px\" \/><\/figure>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-vertically-aligned-center is-layout-flow wp-block-column-is-layout-flow\">\n<figure class=\"wp-block-image aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"305\" height=\"78\" src=\"https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/LED-circuit.drawio2.png\" alt=\"Simple Arduino circuit diagram showing pin 13 connected to a resistor which is connected to a LED that is grounded from its cathode.\" class=\"wp-image-163\" style=\"width:305px;height:auto\" srcset=\"https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/LED-circuit.drawio2.png 305w, https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/LED-circuit.drawio2-300x77.png 300w\" sizes=\"(max-width: 305px) 100vw, 305px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-alternative-connection\">Alternative connection:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can connect the LED&#8217;s anode to pin 13, and its cathode to a grounded resistor.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"76\" src=\"https:\/\/samerli.com\/en\/lessons\/..\/..\/wp-uploads\/2025\/02\/LED-circuit.drawio3.png\" alt=\"Simple Arduino circuit diagram showing an LED connected to pin 13 from its anode, and connected to a resistor that is grounded from its cathode.\" class=\"wp-image-164\"\/><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-3-code\">3. Code<\/h3>\n\n\n\n<p>In order to upload any code to your Arduino board, you can download and use the Arduino IDE <a href=\"https:\/\/www.arduino.cc\/en\/software\/\" title=\"\">here<\/a>. Make sure you keep your internet connected for the first time after installing the IDE and <strong>give permission to all driver installations<\/strong> so you can upload. After the first time, you shouldn&#8217;t need the internet (unless you want to download code pieces called libraries).<\/p>\n\n\n\n<p>After installing Arduino IDE, you can upload all your codes using the following steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Connect Arduino to your PC through the USB connector (usually a blue wire)<\/li>\n\n\n\n<li>From the top bar (or tools on old versions) choose the board type you are using (Arduino Uno)<\/li>\n\n\n\n<li>Then choose the port (for example COM3). If your PC doesn&#8217;t have a USB port and you are using a USB to serial converter, you may find different options, choose the suitable one.<\/li>\n\n\n\n<li>After selecting everything, click the <strong>upload<\/strong> arrow (pointing right). Make sure you actually wrote code in the IDE, unless you want to upload an empty code to Arduino. <strong>You should upload every time you change you code.<\/strong><\/li>\n<\/ol>\n\n\n\n<p>As your first code, you can copy and paste the below code into Arduino IDE, a simple Arduino code to make the LED blink:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Define pin number\nconst int ledPin = 13; \/\/ LED connected to digital pin 13\n\nvoid setup() {\n  \/\/ Set pin mode\n  pinMode(ledPin, OUTPUT); \/\/ Set the LED pin as an output\n}\n\nvoid loop() {\n  \/\/ Turn the LED on\n  digitalWrite(ledPin, HIGH); \/\/ Send HIGH signal to turn on the LED\n  delay(1000); \/\/ Wait for 1 second (1000 milliseconds)\n\n  \/\/ Turn the LED off\n  digitalWrite(ledPin, LOW); \/\/ Send LOW signal to turn off the LED\n  delay(1000); \/\/ Wait for 1 second\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"aioseo-how-this-code-works\">How This Code Works:<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Variable Declaration<\/strong>: At the beginning, we store the number <code>13<\/code> into the variable <code>ledPin<\/code> to represent the pin where the LED is connected.<\/li>\n\n\n\n<li><strong>Setup<\/strong>: The <code>pinMode()<\/code> function sets the <code>ledPin<\/code> as an output pin, meaning it will send signals to the LED.<\/li>\n\n\n\n<li><strong>Loop<\/strong>:<\/li>\n\n\n\n<li>The <code>digitalWrite()<\/code> function turns the LED on by sending a <code>HIGH<\/code> signal and off by sending a <code>LOW<\/code> signal.<\/li>\n\n\n\n<li>The <code>delay()<\/code> function pauses the program for a specified time (in milliseconds). Here, it pauses for 1 second between turning the LED on and off.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-4-tips-for-modification\">4. Tips for Modification<\/h3>\n\n\n\n<p>Now that you you know how to make a simple blinking LED project with Arduino, it may be a good idea to take the next step<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Change Blinking Speed<\/strong>: Modify the <code>delay()<\/code> values to make the LED blink faster or slower.<\/li>\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Example: <code>delay(500)<\/code> for 0.5 seconds or <code>delay(2000)<\/code> for 2 seconds.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Multiple LEDs<\/strong>: Add more LEDs and control them independently by connecting them to different pins and modifying the code. When you are done, check our <a href=\"https:\/\/samerli.com\/en\/lessons\/?p=13\" title=\"Lesson 2: Making a Traffic Light Project With Arduino\">traffic light project<\/a>.<\/li>\n\n\n\n<li><strong>Patterns<\/strong>: Create custom blinking patterns, such as Morse code or alternating blinks between multiple LEDs.<\/li>\n\n\n\n<li><strong>Brightness Control<\/strong>: Use PWM (Pulse Width Modulation) pins (marked with ~, pins 3, 5, 6, 9, 10, or 11 on Arduino Uno) and the <code>analogWrite()<\/code> function to control the LED brightness. Ex: analogWrite(3,124) for halfing brightness.<\/li>\n\n\n\n<li><strong>External Input<\/strong>: Add a push button to control when the LED blinks, as in our <a href=\"https:\/\/samerli.com\/en\/lessons\/?p=29\" title=\"Lesson 3: Multiple Traffic Light Circuit With Arduino\">lesson 3<\/a>. For example, the LED only blinks when the button is pressed.<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"aioseo-6-frequently-asked-question-faqs\">5. Frequently Asked Question (FAQs)<\/h3>\n\n\n\n<div data-schema-only=\"false\" class=\"wp-block-aioseo-faq has-medium-font-size\" id=\"aioseo-doesnt-the-resistor-have-to-be-before-the-led-to-protect-it\"><h4 class=\"aioseo-faq-block-question\">Why does my Arduino blink pin 13 even before I upload the code<\/h4><div class=\"aioseo-faq-block-answer\">\n<p>Some Arduino boards come with the simplest blinking code uploaded<\/p>\n<\/div><\/div>\n\n\n\n<div data-schema-only=\"false\" class=\"wp-block-aioseo-faq has-medium-font-size\" id=\"aioseo-doesnt-the-resistor-have-to-be-before-the-led-to-protect-it\"><h4 class=\"aioseo-faq-block-question\">What does the resistor do?<\/h4><div class=\"aioseo-faq-block-answer\">\n<p>The resistor protects the LED from getting too much current. In electronics, the amount of current (how fast electrons flow) depends on the pushing force (the voltage) and the resisting force (resistance).<br>The bigger the resistor, the slower the flow (less current).<\/p>\n<\/div><\/div>\n\n\n\n<div data-schema-only=\"false\" class=\"wp-block-aioseo-faq has-medium-font-size\" id=\"aioseo-doesnt-the-resistor-have-to-be-before-the-led-to-protect-it\"><h4 class=\"aioseo-faq-block-question\">Doesn&#8217;t the resistor have to be before the LED to protect it?<\/h4><div class=\"aioseo-faq-block-answer\">\n<p>NO, the resistor can be AFTER or before the LED. As long as it is in series (on the same pipeline) with the LED, it can still protect it<\/p>\n<\/div><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>This simple blinking LED project is a great starting point for learning Arduino. You can expand it in countless ways as you gain more experience! Enjoy experimenting!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Making a simple blinking LED project with Arduino is the starting point where many start. This short lesson can help you start your journey learning coding and electronics with Arduino.<\/p>\n","protected":false},"author":1,"featured_media":61,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[9],"class_list":["post-59","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","tag-arduino"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/posts\/59","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=59"}],"version-history":[{"count":6,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions"}],"predecessor-version":[{"id":227,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/posts\/59\/revisions\/227"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=\/wp\/v2\/media\/61"}],"wp:attachment":[{"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=59"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=59"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samerli.com\/en\/lessons\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=59"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}