Potentiometer (ADC)
Lab 3: Potentiometer (ADC) — อ่านค่า Analog
วัตถุประสงค์
จะได้เรียนรู้อะไร
หลักการ ADC
Analog Input ┌─────────┐ Digital Output
(0 - 1.8V) ────► │ ADC │ ────► (0 - 4095)
└─────────┘ 12-bit
Analog Input (0V - 1.8V) ADC Digital Output (0 - 4095)
│ │ │
1.8V ├────────────────────┼─────────────→ 4095
0.9V ├────────────────────┼─────────────→ 2048
0.0V ├────────────────────┼─────────────→ 0Hardware Info
Component
Pin
หมายเหตุ
Lab 3.1 : แก้ไข Macros เดิมจาก
เป็น Macros ใหม่ , เพิ่ม Variables และ ชื่อฟังก์ชันเพิ่มเติม ดังนี้
สร้างฟังก์ชัน init_adc()
สร้างฟังก์ชัน read_potentiometer_mv()
สร้างฟังก์ชัน get_pot_percentage()
ปรับปรุง main() ใหม่
ตัวอย่าง Output บน Serial Terminal
ADC Potentiometer Flowcharts
Overall Program Flow and init_adc() Flowchart

read_potentiometer_mv() Flowchart
get_pot_percentage() Flowchart
ADC Conversion Diagram
Program Code ทั้งหมด
✍️ Exercise
Last updated
Was this helpful?