# Hardware and Interfaces Usage CLI

## **What is GPIO**

&#x20;    General-purpose input/output (GPIO) เป็น pin หรือขาที่ยืนออกมาจากวงจรหรือบอร์ด เราสามารถกำหนดการทำงานของ pin ได้ว่าจะให้ทำหน้าที่เป็น input หรือ output  การเริ่มใช้งาน GPIO ให้ตรวจสอบที่บอร์ดของเราตามข้อมูล Datasheet ส่วนมากจะสามารถหาได้ โดยค้นหาคำว่า Pinout และถ้าพบว่า pin ได้เป็นประเภท GPIO แสดงว่าเราสามารถเขียนโปรแกรมควบคุมกำหนดหน้าที่ของ pin นั้นได้ ถ้า pin นั้นยังไม่ถูกใช้งาน

### **GPIO Schemes**&#x20;

&#x20;    สำหรับ Raspberry Pi GPIO Schemes จะแบ่งการเรียกใช้งานเป็น 2 ส่วนดังนี้

* **GPIO.Board** เป็นการเรียกใช้งานโดยจะยึดตามเลข pin  โดยเรียงการนับจากบนซ้ายไปขวาและลงมาเรื่อย ๆ&#x20;
* **GPIO.BCM** เป็นการเรียกใช้งานโดยจะยึดหน้าที่หรือประเภทของ pin ตามเลข “Broadcom SoC channel” จะ เรียงตัวเลขนับเฉพาะ pin ที่เป็นประเภท GPIO     &#x20;

&#x20;    สังเกตุจากภาพ pinoutt Raspberry Pi ที่ได้จากคำสั่งด้านล่าง ตัวเลขท้าย GPIO สีเขียว คือเลข GPIO.BCM แต่ตัวในวงเล็บคือเลขของ GPIO.Board     ในส่วนของ Raspberry Pi เราสามารถตรวจสอบตำแหน่งและจำนวนของ GPIO โดยให้ทำการ SSH เข้า Raspberry Pi และใช้ Command line ดังนี้<br>

**คำสั่ง:** แสดงข้อมูลบอร์ด Raspberry Pi

```typescript
pinout
```

<div align="center"><img src="https://paper-attachments.dropbox.com/s_69567F42073B5C10111FA6C33D810A755A5FDB1E6515753D75E92E453746F365_1658308337502_image.png" alt="Figure: pinout RaspberryPi"></div>

![Figure: raspberrypi.com](https://paper-attachments.dropbox.com/s_EEE636D9526C071EE54566BA4F9747132A170266CA6042B3ED8970E1C8CEED04_1660624049331_file.png)

### **GPIO Schemes of CrowPi**&#x20;

&#x20;    สำหรับ Raspberry Pi สามารถใช้ sensor บนบอร์ด CrowPi ได้โดยเชื่อมต่อ pin ตามตำแหน่ง จะอยู่ตำแหน่งดัง

ภาพด้านล่าง&#x20;

![Figure: Document CrowPi\_Python\_Lessons.pdf of www.elecrow.com](https://paper-attachments.dropbox.com/s_EEE636D9526C071EE54566BA4F9747132A170266CA6042B3ED8970E1C8CEED04_1660466227239_image.png)

Date: May 2023

Author: Soontree Jaikhong (AIC-Researcher)

Author: Thanaluk Pranekunakol (AIC-Researcher)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aic-eec.com/general/development-on-crowpi/hardware-and-interfaces-usage-cli.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
