กลับไปหน้ารวมไฟล์
arduino-led-blink-07d537-en.md

The "Blink" project is akin to the first step or "Hello World" of the embedded systems world. While seemingly simple, getting an LED to blink involves understanding three fundamental principles: I/O Configuration, Digital Output Control, and Timing Management.

Operation Details and Engineering Principles

In this project, we will instruct the microcontroller to control a digital signal pin to supply voltage to an LED. Here are the in-depth details:

1. Hardware Components

  • Microcontroller (Arduino Board): The core for processing the commands we write.
  • Built-in LED (Pin 13): Most Arduino boards come with an on-board LED connected to Digital Pin 13, making it convenient for initial code testing without external circuitry.
  • Current Limiting Resistor: In engineering practice, an LED must have a resistor to limit the current flowing through it to prevent damage (for Pin 13 on the board, this resistor is usually built-in).

2. Code Logic Analysis

This code is divided into two main parts according to the Arduino Framework standard:

The Setup Configuration

void setup()
{
  pinMode(13, OUTPUT);
}

In the setup() function, the system runs only once when power is first applied. Engineers use this section to define the operating mode of the General Purpose Input/Output (GPIO) pins. The pinMode(13, OUTPUT) command instructs the processor to prepare the internal circuitry for Pin 13 to act as an "output" path, enabling it to supply current to drive the LED.

The Main Loop

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

The loop() function continuously repeats in the following sequence:

  1. digitalWrite(13, HIGH): Sets Pin 13 to a "HIGH" state, meaning it outputs voltage (approximately 5V or 3.3V, depending on the board type), completing the circuit and lighting up the LED.
  2. delay(1000): A delay command, specified in milliseconds (ms). Here, it's 1000 ms or 1 second. During this time, the microcontroller pauses and maintains the LED in the ON state.
  3. digitalWrite(13, LOW): Sets Pin 13 to a "LOW" state, or 0V (Ground), cutting off the power supply and turning the LED OFF.
  4. delay(1000): Delays for another 1 second to observe the OFF state before the loop returns to the first line.

Summary of Operation

The result is a blinking light circuit with a Duty Cycle of 50% and a blinking frequency of 0.5 Hz (ON for 1 second, OFF for 1 second, totaling one cycle every 2 seconds). This forms a crucial foundation for future applications, such as implementing warning signals or controlling the timing of machinery.

ข้อมูล Frontmatter ดั้งเดิม

title: "Arduino LED Blink"
description: "Turns an LED on for one second, then off for one second, repeatedly."
author: "MinukaThesathYapa"
category: ""
tags: []
views: 1628
likes: 1
price: 99
difficulty: "Easy"
components:
  - "1x Arduino UNO"
  - "1x LED (generic)"
  - "1x Resistor 220 ohm"
  - "1x Breadboard (generic)"
  - "2x Jumper wires (generic)"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles:
  - "https://projects.arduinocontent.cc/fa64f64d-b834-45ae-850f-4be7e3da3e96.ino"
documentationLinks: []
passwordHash: "cb99c27b5797370a020f3133b7aa17ad0cb11116a782f0d60c7cf4c3d6d1e2f9"
encryptedPayload: "U2FsdGVkX19Ug+8MRexKJ02cCljne5e1Vo4jrUcYwwNG4UDdm/KJtGaXcDDevF+cCJ+0Qf7fCYH5UiL3gG35odBliOM2NqRXJepXwIHEQto="
seoDescription: "Learn how to blink an LED using Arduino. A perfect starter project for beginners to understand basic coding and hardware control."
videoLinks: []
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/arduino-led-blink-07d537_cover.jpg"
lang: "en"