Skip to main content

Arduino - Button

Arduino - Button

Button And Switch
This article will give an example how to use Arduino board with a switch. The Arduino board reads the digital status of the switch as an input to execute an your functions.

There are two types of switching circuits.

  1. pull-up (Normally the status is '1', If you press the button status is set to '0')
  2. pull-down (Normally the status is '0', If you press the button status is set to '1')
Switching circuit, pull-down

In this article, we will select a pull-up circuit (Normally the status is '1', If you press the button status is set to '0')
Example.
pull-up circuit switch
Example Program
Arduino has special functions for internal pull-up circuits. So we can use only switch. (Must be declared as INPUT_PULLUP)
Internal pull-up circuit switch
Example Program
After uploading the program onto the Arduino board, see the results of running the program from Serial Monitor or Serial Plotter.
 Serial Monitor
Serial Plotter

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 คืออะไร

Arduino คืออะไร         Arduino อ่านว่า (อาดุยโน่ หรือ อา-ดู-อิ-โน่) เป็นเเพลตฟอร์มอิเล็กทรอนิกส์แบบโอเพนซอร์สบน พื้นฐานของฮาร์ดแวร์และซอฟท์แวร์ที่ง่ายต่อการใช้งาน สามารถนำไปประยุกต์ใช้งานได้หลายอย่าง เช่น ควบคุมอุปกรณ์อิเล็กทรอนิกส์ขนาดเล็ก อ่านค่าเซ็นเซอร์วัดสภาพแวดล้อมต่างๆแล้วแสดงค่าที่เซ็นเซอร์สามารถอ่านได้ออกมาทางจอแสดงผล นำไปประยุกต์เข้าเป็นชิ้นงานทางอิเล็กทรอนิกส์เพื่ออำนวยความสะดวกในการใช้ชีวิตประจำวัน เป็นต้น         ปัจจุบัน Arduino ถือได้ว่าเป็นเเพลตฟอร์มที่ได้รับความนิยมสูงจากทั่วโลก เนื่องมากจากราคาของตัวบอร์ด Arduino ไม่ค่อยสูงมาก เป็นโอเพนซอร์สทั้งทางด้านฮาร์ดแวร์และซอร์ฟแวร์ คอมมิวนิตี้และฟออรัมน์ในการถามตอบเรื่องเกี่ยวกับการใช้งานร่วมกับอุปกรณ์อิเล็กทรอนิกส์ต่างๆ ตัวอย่างโปรแกรมเบื้องต้นและไลบรารี่สำหรับใช้งาน และอื่นๆ ใน แพลตฟอร์มของ Arduino ประกอบไปด้วยส่วนหลักๆ 2 ส่วน คือ 1. ส่วนของฮาร์ดแวร์         บอร์ด Arduinoเป็นวงจรอิเล็กทรอนิกส์ขนาดเล็กที่มีไอซีหรือชิพประมวลผลของไมโครคอนโ...