Skip to main content

Arduino กับการอ่านค่าความต่างศักย์

Arduino กับการอ่านค่าความต่างศักย์

สัญญาณอนาล็อก
ในบทความนี้จะเป็นบทความต่อเนื่องจาก บทความ Arduino กับการอ่านค่าแอนะล็อก โดยจะอาศัยหลักการอ่านค่าแอนะล็อกมาจากตัวต้านทานปรับค่าได้เหมือนกัน แต่จะเพิ่มการคำนวนโดยแปลงค่าแอนะล็อกที่อ่านได้จาก 0-1023 กลับไปเป็นค่าความต่างศักย์ 0-5V

วิธีการแปลงค่าแอนะล็อกเป็นค่าความต่างศักย์สามารถทำได้โดยการหาค่าที่ละเอียดที่สุดของบอร์ดที่สามารถอ่านได้จากนั้นนำไปคูณกับค่าแอนะล็อกของบอร์ดที่สามารถอ่านได้ หรือใช้สูตร
ความต่างศักย์ = ค่าแอนะล็อกที่บอร์ดอ่านได้ * 5 / 1023
Arduino อ่านค่าแอนะล็อกจากตัวต้านทานปรับค่าได้
ตัวอย่างโปรแกรมที่ใช้

หลังจากอัพโหลดโปรเเกรมลงบนบอร์ด Arduino ดูผลลัพธ์การรันโปรแกรมได้จาก Serial Monitor หรือ Serial Plotter
Serial Monitor
Serial Plottor

Comments

Popular posts from this blog

Arduino กับการใช้งาน Serial Monitor

Arduino กับการใช้งาน Serial Monitor Serial Monitor คือ ส่วนหนึ่งของโปรแกรม Arduino IDE สามารถใช้งานได้ 2 อย่าง คือ - แสดงผลลัพธ์จากบอร์ด Arduino - ใช้รับข้อมูลจากผู้ใช้ แล้วส่งข้อมูลไปยังบอร์ด Arduino รูปแบบการใช้งาน Serial Monitor เริ่มต้นใช้งาน void setup() {    Serial.begin(9600); } แสดงผลออกทาง Serial Monitor Serial.print("Hello World");       /* แสดงคำว่า Hello World */ Serial.println("Hello World");     /* แสดงคำว่า Hello World และขึ้นบรรทัดใหม่ */   อ่านค่าจาก Serial Monitor Serial.read(); วิธีเปิด Serial Monitor 1. กด Ctrl + Shift + M 2. กด Icon ตัวอย่างการแสดงผลลัพธ์จากบอร์ด Arduino แสดงผลลัพธ์จากบอร์ด Arduino ตัวอย่างการรับค่าจาก Serial Monitor - ส่ง 1 เพื่อ On LED -  ส่ง 0 เพื่อ Off LED แสดงผลลัพธ์การรับค่าจาก Serial Monitor * ถ้าไม่สำเร็จ ตรวจสอบว่าเลือก No line ending และบอดเรทเป็น 9600 เเล้วหรือยัง

Arduino - How to use Liquid Crystal Display I2C

Arduino - How to use Liquid Crystal Display I2C In this article will be How to use Arduino board with Liquid Crystal I2C, It same  Arduino Lcd Liquid Crystal Display    Examples applications, Arduino boards send text or output from sensor to show on LCD screen.  But there is another control unit (PCF8574) to control the screen. This reduces the number of pins to 4 lines. Details of PCF8574 (LCD  Controller ) Signal pin (i2c) from Arduino Board Potentiometer for adjust Contrast of character Address Selector pad Black light jumper  Circuit Install Library go to Library Manager -> Search  "LiquidCrystal i2c" -> Install  ( See more ) Scan I2C Adress  of  PCF8574  (LCD  Controller ) Check connection and Search Address  of  PCF8574  (LCD  Controller )  ( See more ) After find the PCF8574 Address, Take this in Example Code (0x27 or 0x3F) Example Code outpu...