บทความประกอบการเรียนรู้ => ไมโครคอนโทรลเลอร์ (Arduino) => ข้อความที่เริ่มโดย: admin ที่ เมษายน 29, 2014, 12:56:30 PM
-
เขียนโปรแกรมแสดงผลค่า 7 Segment 4 digit จากเซนเซอร์แอนนาลอก
ฟังก์ชั่นที่ใช้งาน
-analogRead() http://arduino.cc/en/Reference/AnalogRead (http://arduino.cc/en/Reference/AnalogRead)
-map() http://arduino.cc/en/reference/map (http://arduino.cc/en/reference/map)
-delay() http://arduino.cc/en/Reference/Delay (http://arduino.cc/en/Reference/Delay)
-millis()http://arduino.cc/en/Reference/Millis (http://arduino.cc/en/Reference/Millis)
ไลบารี่เพิ่มเติม
-Multiplex7Seg.h (ไลบรารี่ตัวเดียวกันกับงานครั้งที่ 16 หากติดตั้งแล้วไม่ต้องทำซ้ำ)
*ดูวิธีติดตั้งในงานครั้งที่ 16 (http://www.praphas.com/forum/index.php?topic=262.0)
ฟังก์ชั่นในไลบารี่ Multiplex7Seg.h
จะต้องประกาศตัวแปลระบุขาต่อกับ 7 segment ก่อนใช้งาน (ประกาศแบบ global นอกฟังก์ชั่น setup,loop)
byte digitPins[] = {9, 10, 11, 12}; // LSB to MSB
byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8}; // Segment a to g
-Multiplex7Seg::set(1, 4, digitPins, segmentPins); //1=enable,4=4 digit
-Multiplex7Seg::loadValue(value);
โจทย์โปรแกรม
-เทอร์โมมิเตอร์ (Temp sensor)แสดงค่าอุณหภูมิเป็นตัวเลขที่ 7 segment 4 digit
-โวลท์มิเตอร์ (เรนจ์ 0-30V)แสดงผลตัวเลขที่ 7 segment 4 digit
-มิเตอร์วัดแสง (เรนจ์ 100-900)แสดงผลตัวเลขที่ 7 segment 4 digit
-โปรแกรมรายละเอียดพิเศษรายกลุ่ม (แจ้งให้ทราบเมื่อถึงชั่วโมงเรียน)
วงจรที่ใช้ในการทดลองสำหรับผู้ที่ใช้บอร์ด Arduino
(http://www.praphas.com/PhotoForum/arduino/Lab-19-01.png)
วงจรที่ใช้ในการทดลองสำหรับผู้ที่ใช้ไอซี ATmega328 (ที่มี Boot Loader Arduino)
(http://www.praphas.com/PhotoForum/arduino/Lab-19-02.png)
บริเวณใช้งานบอร์ดทดลอง
(http://www.praphas.com/PhotoForum/arduino/Lab-19-03.png)