กลับไปหน้ารวมไฟล์
working-with-an-led-and-a-push-button-d34b17-en.md

This project demonstrates the use of a push button to operate a LED.

Objective:

  • To Set LED ON when Button is pressed.
  • To Set LED OFF when Button is pressed (the opposite effect).
Working with a Push Button

Interaction Basics: LED and Button

Every great invention starts with a single interaction. Controlling an LED with a push button is the "Hello World" of physical computing. This project introduces the core concepts of digital reads and digital writes.

The Logic Flow

The Arduino acts as a mediator in this circuit:

  1. Input: The Arduino reads the state of a GPIO pin connected to the button.
  2. Analysis: If the button is pressed, the pin reads HIGH (or LOW depending on your circuit).
  3. Output: Based on that state, the Arduino sends a signal to another pin to turn the LED ON or OFF.

Hardware Setup: The Pull-Down Resistor

A common mistake for beginners is connecting a button directly between power and an input pin. This leaves the pin "floating" when the button isn't pressed, leading to erratic behavior.

  • Solution: We use a 10k-ohm resistor connected to Ground (a pull-down resistor). This ensures the pin sees a stable LOW signal until the button is pressed.

Components List

  • Arduino (any model): To process the signals.
  • LED (any color): Your visual output.
  • Push Button/Tactile Switch: Your physical input.
  • 220-ohm Resistor: For the LED.
  • 10k-ohm Resistor: For the button pull-down.

This simple setup is the basis for almost every user interface in the world, from microwave buttons to industrial control panels.

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

apps:
  - "1x Arduino IDE"
author: "SBR"
category: "Basic Electronics"
components:
  - "1x Breadboard (generic)"
  - "2x Resistor 1k ohm"
  - "5x Jumper wires (generic)"
  - "1x Arduino UNO"
  - "1x LED (generic)"
description: "The fundamental building block of interactive electronics. Learn how to use a digital input (button) to control a digital output (LED) with Arduino."
difficulty: "Easy"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX1+fCAbjMkoU7SBqI6XDy39ewffahpcdjKxA7TlYnbyv/0O58ADdxiKxSXSghG/Y8lnMSXCqnhiJjYlg1ACTptg6cY5AD5lOfcDkiIcRlROWEND2yfMU3SCS86aYItgfjk8FfEH3BmODmsrIHxVjsrL0Er637nPlKFq1x0C+BZvOAjvBgDEH8f2l"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/working-with-an-led-and-a-push-button-d34b17_cover.jpg"
lang: "en"
likes: 23
passwordHash: "dc4edc0ede9da7581da9e92f2fe08c0c0370eb9b7be62dd7d2179471dc34f178"
price: 1499
seoDescription: "Learn how to control an LED using a Push Button with Arduino. Simple step-by-step guide for beginners."
tags:
  - "starter"
  - "learners"
  - "beginners"
title: "Working with an LED and a Push Button"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/quJ8C_eL3MA"
views: 289354