# wiringPi library (C) for CrowPi

1. เปิดโปรแกรม Vscode เชื่อมต่อ VScode เข้ากับ WSL
2. สร้างไดเรคทอรี่ของตัวเองขึ้นมา แล้วเข้าไปยังภายในไดเรคทอรี่

```
mkdir Jameza007
cd Jameza007
```

3\. ทำการโคลนไฟล์ชุดคำสั่งภาษา C จากลิ้ง github <https://github.com/absayuti/crowpi> โดยใช้คำสั่งดังนี้

```
git clone https://github.com/absayuti/crowpi
```

4\. คัดลอกไดเรคทอรี่ที่มีไฟล์ Crowpi ที่ดาวน์โหลดในขั้นตอนที่ 3  ไปยัง RaspberryPi

```
scp -r Jameza007 pi@[ip_address_of_Rpi]:~/
```

5\. ทำการ Secure shell (ssh) เข้า RaspberryPi

```
ssh pi@[ip_address_of_Rpi] 
```

{% hint style="warning" %}
password RaspberryPi : raspberry
{% endhint %}

6\. ใช้คำสั่ง ls เพื่อ แสดงไฟล์อยู่ใน RaspberryPi&#x20;

```
ls
```

7\. ใช้คำสั่ง cd เข้าไปยังไดเรคทอรี่ที่ได้คัดลอกจากคอมพิวเตอร์มายัง RaspberryPi และเข้าไปยังดเรคทอรี่ crowpi

```
cd Jameza007/crowpi
```

8\. ทำการทดลอง complie โปรแกรมชุดคำสั่งภาษา C ของแต่ละเซนเซอร์โดยใช้คำสั่งดังนี้&#x20;

```
gcc ไฟล์โค้ด.c -o ชื่อไฟล์ที่จากComplie -lwiringPi -Wall
```

{% hint style="warning" %}
ชื่อไฟล์ที่ได้จากการcomplie ให้ตั้งชื่อดังนี้ ชื่อไฟล์โค้ด\_รหัสนิสิต
{% endhint %}

ตัวอย่าง complie sensor DHT11 ไฟล์ temphumidity.c

![](https://1856353139-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MClo3nC-1US0rbK8Qau%2F-MP8IoZSYv5n8mgcW_Fv%2F-MP8KYK9AH4eFL5LQDsZ%2Fimage.png?alt=media\&token=5cc2f739-1e44-463d-9169-f1d3f180673d)

9.เมื่อได้ไฟล์ complie แล้ว ให้ทำการ Run โปรแกรมด้วยคำสั่งดังนี้

```
./ชื่อไฟล์ที่จากComplie
```

ตัวอย่าง Run โปรแกรม temphumidity\_รหัสนิสิต และผลการทำงาน

![](https://1856353139-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MClo3nC-1US0rbK8Qau%2F-MP8IoZSYv5n8mgcW_Fv%2F-MP8LDV4ULubCT-dULYS%2Fimage.png?alt=media\&token=d901dda5-c481-4b46-bb60-531c8a3adbf8)

Date: May 2023

Author: Soontree Jaikhong (AIC-Researcher)

Author: Thanaluk Pranekunakol (AIC-Researcher)
