# \[BASIC] 001 Debug (ดีบัก)

สวัสดีครับ สำหรับหัวข้อบทเรียนพื้นฐานบนบอร์ด HONEYLemon ที่ใช้งานผ่าน arduino library ในเรื่องนี้จะนำพาท่านไปพบกับการใช้งาน Debug Mode เพื่อดูรายละเอียดต่างๆ ของการทำงานบนบอร์ด HONEYLemon ซึ่งจะทำให้ท่านสามารถตรวจหาสาเหตุ เหตุการณ์ต่างๆ ที่เกิดขึ้นบนบอร์ดผ่านการเขียน code

การ debug นี้จำเป็นต้องใช้งานร่วมกับ Serial เพื่อจะใช้ Serial Monitor ในการแสดงผล ดังนั้น ลำดับแรกเราจึงมีการเรียกใช้งาน Serial.begin() ขึ้นมา และมีการขอดู debug ผ่านคำสั่ง lemon.debug() ตัวอย่าง code เบื้องต้นจะเป็น

```
Serial.begin(115200);
lemon.debug(Serial);
```

&#x20;**ตัวอย่าง source code**

```
/*
    Basic : การเขียนโปรแกรมเพื่อดู debug บนบอร์ดไมโครคอนโทรลเลอร์ HONEYLemon
*/
#include <HONEYLemon.h>

void setup()
{
    lemon.begin();          // เรียกใช้งานฟังก์ชั่นเริ่มต้นของบอร์ด HONEYLemon

    Serial.begin(115200);   // เรียกใช้งาน Serial
    lemon.debug(Serial);    // ขอดู debug ของบอร์ด HONEYLemon ผ่าน Serial
}

void loop()
{
}
```

&#x20;**ตัวอย่าง การแสดงผลผ่าน Serial Monitor**

![](/files/-MA5pIDnyY2BPIphIEwY)


---

# 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://lemon.honey.co.th/blogs/basic/basic-001-debug.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.
