# RemoteXY - Arduino

## เริ่มต้นต้องติดตั้ง โปรแกรม KBIDE ก่อนตามลิงค์ด้านล่างเลย

{% content-ref url="/pages/-MPmw70lW75EmC0-twPJ" %}
[Arduino IDE Install](/getstart/arduino-ide-1.md)
{% endcontent-ref %}

### Library ที่จำเป็นต้อง ติดตั้งเพิ่มเติม "Remote XY"

![](/files/-MaZI0TnDjOHmVjfsdON)

### **ดาวน์โหลดตัวอย่าง Code Arduino**

ในตัวอย่างโปรแกรม Drone ในฝั่งของ Arduino IDE จะคล้ายกับ KBIDE เนื่องจากใช้ SDK ตัวเดียวกันจึงทำให้สามารถรันข้าม  Platform กันได้เริ่มต้น Download Code จากลิงค์ด้านล่างกันก่อนเลย

{% hint style="success" %}
[คลี๊กดาวน์โหลดตัวอย่างโปรแกรมโดรนบน Arduino IDE](https://github.com/MakerAsia/kb32-ft)
{% endhint %}

![](/files/-MdVyKl5KHbSZSg6kQEc)

สามารถกดปุ่มสีเขียว **Download "Code"** หลังจากนั้นแตกไฟล์ให้เรียบร้อยก็จะได้ SDK Drone Kit ที่พร้อมพัฒนากันแล้ว

![ รูปไฟล์ SDK ที่อยู่บนเครื่องคอมพิวเตอร์](/files/-MaZ883jSqC_eh3qKBMZ)

ไฟล์ SDK Drone Kit จะมี Library ที่จำเป็นและถูกดัดแปลงมาให้สามารถใช้งานกับชุดคิทได้ จึงต้องใช้ Library ที่เราพัฒนาขึ้นมาเพื่อให้เจ้า Drone Kit มีความสามารถการบินที่ดีที่สุดบนบอร์ด KB32-FT

{% hint style="success" %}
**เปิดไฟล์ kb32ftdrone.ino**
{% endhint %}

![ภาพแสดงการสร้าง Folder](/files/-MaZ95-CMPWNT0wkH-8g)

เมื่อดับเบิ้ลคลิ๊กเปิดไฟล์เสร็จจะมี Popup เด้งให้สร้าง folder ขึ้นมาใหม่ ให้กด **"Cancel"** หรือ กด **"OK"** เพื่อสร้าง folder ใหม่แต่ต้องย้ายไฟล์ Library ตามเข้าไปใน folder ด้วย

{% hint style="info" %}
กด Cancel เพื่อไม่ต้องสร้าง folder ขึ้นมาให้ใช้ folder ให้ Libbrary อยู่ใน folder เดียวกัน
{% endhint %}

{% hint style="info" %}
กด OK เพิ่มสร้าง folder ขึ้นมาแต่จำเป็นต้องย้าย Libbrary ไปอยู่ใน folder เดียวกัน
{% endhint %}

![หน้าต่างตัวอย่าง โปรแกรมบน Arduino IDE](/files/-MaZABVAr-g6szAk294V)

{% hint style="warning" %}
เลือกบอร์ด ESP32 Dev Module และทดลองกด Compile ดูว่าโปรแกรมรันผ่านหรือไม่
{% endhint %}

{% hint style="success" %}
ใน ESP32 Version ถัดไปจะสามารถเลือกบอร์ด KB32-FT บน โปรแกรม Arduino IDE ได้แล้ว
{% endhint %}

### ตัวอย่างการคาริเบท DroneCal

ในขั้นตอนแรกตัวอย่างโปรแกรม DroneCal เป็นการเรียกอ่านค่าเริ่มต้นของเซนเซอร์ Accelerometer และ Gyroscope ของชิพ MPU-6050 ซึ่งใช้เป็นค่า offset ของโดรน&#x20;

#### ขั้นตอนแรกคาริเบท&#x20;

สังเกตุในบรรทัดที่ 291 - 300 จะเป็นการเปิดและปิดโหมดคาริเบทพร้อมใส่ค่าตัวแปรที่คาริเบทได้

![](/files/-MaZDvu4bdp_cUqNnFp6)

ตัวอย่าง Code เริ่มต้นจะเป็นตัวอย่าง Calibration อยู่แล้วสามารถ Uplode โปรแกรมได้เลย เมื่อUpload เสร็จแล้วทดลองเปิด Serial port

{% hint style="warning" %}
**Serial Monitor** เลือก **COMPORT .....** ตาม Port KB32-FT **Serial Uplaod Baudrate : 115200**

กด >>>> **Connect** >>>>  หากไม่มีข้อความแสดงให้ **กดปุ่ม Reset บนบอร์ด KB32-FT**
{% endhint %}

![](/files/-MaZEqGOldj2kfTicBcx)

เมื่อเปิดเมนู **Serial Monitor** แล้วตัวโปรแกรมจะแสดงค่า Accl , Gyro ของทั้ง 3 แกน จะมีทั้งหมด 6 ตัวแปร

**ตัวอย่างค่าที่แสดงผล (เครื่องหมายลบ - ต้องพิมพ์ด้วย) ซึ่งโดรนแต่ละลำจะมีค่าที่อ่านได้ไม่เหมือนกัน**

| **X Accel** | **Y Accel** | **Z Accel** | **X Gyro** | **Y Gyro** | **Z Gyro** |
| ----------- | ----------- | ----------- | ---------- | ---------- | ---------- |
| -4770       | -1243       | 1068        | -32        | -123       | -2         |

{% hint style="warning" %}

### `ให้ทำการจดบันทีกค่าที่แสดงใน Serial Port ไว้ใช้ในตัวอย่างถัดไป`

{% endhint %}

### ตัวอย่างการ Upload Code พร้อมบิน

ปิดหรือคอมเมนต์บรรทัดที่ 298-300 ออกเพื่อไม่ให้โปรแกรมทำงานในโหมดคาริเบท แก้ไขค่าตัวแปรที่ได้จากการคาริเบทจำนวน 6 ตัวแปร จากนั้นกด Upload โปรแกรม

![](/files/-MaZFIi6VJWTKTmSYWoF)

**ตัวอย่างการแก้ไขค่าคาริเบท**

![](/files/-MaZFuaYDLpbmxW0zDiu)

{% hint style="success" %}
เมื่อกด Upload แล้วสามารถใช้ App RemoteXY มาต่อและใช้งานได้เลย
{% endhint %}

#### สำหรับการปรับปรุงแก้ไขตัวแปรต่าง ๆ ในระดับ Advance จะมีคอสสอนออนไลน์เร็ว ๆ นี้สามารถรอติดตามและเรียนกับทีมงานคุณภาพได้เลยรับรองว่าได้ความรู้พร้อมเทคนิคอีกมากมาย


---

# 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://kb32ft.chiangmaimaker.com/drone-kit/drone-developer/remote-xy/arduino-code-programing.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.
