กลับไปหน้ารวมไฟล์
eggtimer-created-using-arduino-and-millis-function-7f7f44.md

ไข่จับเวลาสร้างด้วย Arduino และฟังก์ชัน millis

เมื่อไม่กี่สัปดาห์ที่ผ่านมา ผมได้โพสต์บทช่วยสอนเกี่ยวกับฟังก์ชัน millis ซึ่งผมใช้ฟังก์ชันนี้ในการทำ multitask, process slice ใน Arduino Code

ในบทช่วยสอนนี้ ผมจะแสดงให้คุณเห็นถึงวิธีการสร้างกลไก delayed trigger mechanism

ผมใช้มันเพื่อสร้าง eggtimer แต่มันสามารถนำไปใช้กับ projects อื่นๆ ได้หลากหลาย

สามารถดู tutorial ฉบับเต็มได้ที่นี่:

หากคุณชอบเนื้อหานี้และต้องการสนับสนุนผมในการสร้าง videos ที่คล้ายกัน โปรดไปที่ Patreon webpage ของผมที่ https://www.patreon.com/MariosIdeas หรือ https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=7PD67JWZ9S3EJ&source=url

รายละเอียดทางเทคนิคเพิ่มเติม

การนับถอยหลังแบบ Non-Blocking ที่แม่นยำ

project นี้มี timer สำหรับห้องครัวหรือห้องปฏิบัติการที่ทนทาน ซึ่งหลีกเลี่ยงข้อผิดพลาดของฟังก์ชัน delay() ทำให้สามารถทำงานแบบ multiple concurrent tasks ได้

  • Temporal Differential Logic: การ countdown ถูกจัดการโดยใช้ฟังก์ชัน millis() โดย Arduino จะคำนวณความแตกต่างระหว่าง "Target Time" และ "Current Time" ในทุก loop ทำให้ timer ยังคง frame-perfect แม้ว่าจะมีการอ่านค่าจาก sensors อื่นๆ อยู่ก็ตาม
  • Rotary Encoder Navigation: ใช้ rotary encoder ที่ทนทานสำหรับการ time setting โดย Arduino IDE 2.0 Beta ถูกนำมาใช้เพื่อ implement algorithm "Smooth Scrolling" ซึ่งเมื่อผู้ใช้หมุน knob เร็วขึ้น เวลาจะ increments ในขั้นที่ใหญ่ขึ้น (1m เทียบกับ 15m)

การแจ้งเตือน

  • Dynamic Alarm Frequency: เมื่อ timer นับถึงศูนย์, Arduino จะทริกเกอร์ 90dB piezo siren ที่ ramps up in frequency ทำให้ผู้ใช้ได้ยินเสียงจากทั่วบ้าน

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

title: "Eggtimer created using Arduino and millis function"
description: "I continue to experiment with millis function."
author: "Dziubym"
category: "Screens & Displays"
tags:
  - "oled"
  - "eggtimer"
  - "millis"
views: 3229
likes: 0
price: 1120
difficulty: "Intermediate"
components:
  - "1x Buzzer"
  - "1x Arduino"
  - "1x OLED SSD1306"
  - "1x Arduino Nano R3"
tools: []
apps:
  - "1x Arduino IDE 2.0 (beta)"
downloadableFiles: []
documentationLinks: []
passwordHash: "f75c8e02671b410cdf7110660a9faa0565f29b31e5c35030c19d8cfe06ac2ace"
encryptedPayload: "U2FsdGVkX18bTrpVBsizhdqwclKrAJtO9eUpvsD2Tmy080Bwwy5ZsUShwfih+C/U5PTHr1hVvoxSh/h3xbpblU0ZB+3APTFL9n1tyitHwq0="
seoDescription: "Create an Eggtimer with Arduino using the millis function for efficient non-blocking timing in your DIY projects."
videoLinks:
  - "https://www.youtube.com/embed/9a5q-xDvZQs"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/eggtimer-created-using-arduino-and-millis-function-7f7f44_cover.jpg"
lang: "th"