กลับไปหน้ารวมไฟล์
control-rgb-led-using-bluetooth-d57796.md

ชื่อโปรเจกต์: Control RGB LED using Bluetooth

สวัสดีทุกคน,

โปรเจกต์นี้จะแสดงให้เห็นถึงวิธีควบคุม RGB LED โดยใช้ Bluetooth ลองดูวิดีโอนี้:


🛠️ เจาะลึก / วิเคราะห์ทางเทคนิค

ทำไมต้องซื้อไฟตกแต่งห้องอัจฉริยะราคา $80 ในเมื่อคุณสามารถสร้างแบบกำหนดเองได้ในราคาเพียง $15? โปรเจกต์ Bluetooth WS2812B Controller ผสมผสานการแยกวิเคราะห์คำสั่ง Serial เข้ากับไลบรารี FastLED เพื่อสร้างแสงสว่างที่สวยงามและตอบสนองได้ดีเยี่ยมสำหรับห้องของคุณ

ความมหัศจรรย์ของไลบรารี FastLED

แถบ WS2812B (NeoPixels) มีสายไฟเพียง 3 เส้น: 5V, GND, และสาย Data เพียงเส้นเดียว

  • เป็นแบบ "Addressable" คุณสามารถสั่งให้ LED ตัวที่ 5 เป็นสีแดงในขณะที่ LED ตัวที่ 60 เป็นสีน้ำเงินได้
  • ไลบรารี FastLED.h จะจัดการเรื่อง Timing ที่ซับซ้อนอย่างยิ่งยวดซึ่งจำเป็นสำหรับสาย Data
  • leds[0] = CRGB::Red; FastLED.show();

การแยกวิเคราะห์สตริง RGB จาก Bluetooth

ความท้าทายที่แท้จริงคือการดึงสีที่แม่นยำจากโทรศัพท์ของคุณ

  1. คุณใช้ Android App (เช่น Bluetooth Electronics) เพื่อเลือกสีม่วงที่กำหนดเองบน Color Wheel
  2. แอปจะส่งสตริงไปยัง HC-05 Receiver: R:150,G:0,B:200\n
  3. Arduino จะอ่านสตริงนั้น โดยใช้ C++ String.indexOf() เพื่อค้นหาเครื่องหมายคอมมา และ String.substring().toInt() เพื่อดึงค่า Integer 150 และ 200 ที่แม่นยำออกมา
  4. จากนั้นจะนำตัวเลขที่แยกวิเคราะห์แล้วเหล่านี้ป้อนเข้าสู่ fill_solid(leds, NUM_LEDS, CRGB(r, g, b)); โดยตรง

คำเตือนเรื่องแหล่งจ่ายไฟ

  • Arduino Uno/Nano: สำหรับ Logic คำสั่ง
  • HC-05 Bluetooth Module
  • Pin ของ Arduino สามารถจ่ายกระแสได้สูงสุด 500mA แถบ NeoPixels ความยาว 1 เมตร ที่มี 60 ดวง และเปิดเป็นสีขาวเต็มที่นั้นกินกระแสถึง 3.6 Amps! คุณ ต้อง จ่ายไฟให้กับแถบ LED ผ่าน 5V/5A power supply ภายนอก หากคุณเสียบแถบ LED เข้ากับ Pin 5V ของ Arduino โดยตรง Voltage Regulator จะไหม้ทันที

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

title: "Control RGB LED using Bluetooth"
description: "This project helps you with the connections of controlling RGB LED with Bluetooth module and Arduino Uno."
author: "kamatalaashish"
category: "Internet of Things, BT & Wireless"
tags:
  - "led"
  - "rgb"
views: 47138
likes: 15
price: 450
difficulty: "Easy"
components:
  - "1x Jumper wires (generic)"
  - "1x HC-05 Bluetooth Module"
  - "1x Arduino UNO"
  - "1x rgb led"
tools: []
apps:
  - "1x color led controller"
downloadableFiles: []
documentationLinks: []
passwordHash: "d53c87ecaec0c87f9e8bf019960dfd56773a9f6c77bce7224024a937e05cc7fc"
encryptedPayload: "U2FsdGVkX19i6P2dDONs1Kgz6iQtnXVttRyrvzfzCDxW5FJv7rdKozM2V60Aka6rrRGrjIgrxCEVJjX214bvTm1cJEZ6h+bZYc+ndLQaepY="
seoDescription: "Learn how to connect and control an RGB LED using a Bluetooth module and Arduino Uno in this easy-to-follow project."
videoLinks:
  - "https://www.youtube.com/embed/AW4amUw-Hwg"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/control-rgb-led-using-bluetooth-d57796_cover.png"
lang: "th"