Search this site
Embedded Files
Skip to main content
Skip to navigation
Gencode Thailand
Home
Courses
Let's Code!
Ladplakao
Plusmall Bangyai
Wanghin
Tutorials
Gen Cool
Gen Cool : micro:bits
Assemble Manual
1. Mobile Shooter
2. Pretty Car
3. Clip Robot
4. Proficient Carrier
5. Skip Car
6. Freestyle
7. Spider
8. Lifting Platform
9. Biped Robot
10. Changing Face
11. Carousel
12. Oscillating Fan
13. Airplane
14. Unicycle
15. Auto-Door
16. Dragon Knight
Gen Cool : Scratch Game
Liveworksheets
Test
Exercises
Contact Us
Gencode Thailand
Home
Courses
Let's Code!
Ladplakao
Plusmall Bangyai
Wanghin
Tutorials
Gen Cool
Gen Cool : micro:bits
Assemble Manual
1. Mobile Shooter
2. Pretty Car
3. Clip Robot
4. Proficient Carrier
5. Skip Car
6. Freestyle
7. Spider
8. Lifting Platform
9. Biped Robot
10. Changing Face
11. Carousel
12. Oscillating Fan
13. Airplane
14. Unicycle
15. Auto-Door
16. Dragon Knight
Gen Cool : Scratch Game
Liveworksheets
Test
Exercises
Contact Us
More
Home
Courses
Let's Code!
Ladplakao
Plusmall Bangyai
Wanghin
Tutorials
Gen Cool
Gen Cool : micro:bits
Assemble Manual
1. Mobile Shooter
2. Pretty Car
3. Clip Robot
4. Proficient Carrier
5. Skip Car
6. Freestyle
7. Spider
8. Lifting Platform
9. Biped Robot
10. Changing Face
11. Carousel
12. Oscillating Fan
13. Airplane
14. Unicycle
15. Auto-Door
16. Dragon Knight
Gen Cool : Scratch Game
Liveworksheets
Test
Exercises
Contact Us
ESP32: การใช้ Serial Monitor
Serial Monitor เป็นเครื่องมือ หรือหน้าต่าง ที่เอาไว้แสดงข้อมูล หรือผลลัพธ์ ที่ได้จากการตรวจสอบการทำงานของโปรแกรม
เราสามารถตรวจดูข้อมูล ที่ใช้รับ-ส่งกันระหว่างคอมพิวเตอร์กับบอร์ดได้
เช่น การดูค่า ที่อ่านได้จากเซ็นเซอร์
การตรวจดู output ที่จุดต่างๆ
การตรวจดูค่าตัวแปร (variable) ในโปรแกรม
การรับ-ส่ง ข้อมูลระหว่างคอมพิวเตอร์ หรือหน้าต่าง Serial Monitor กับบอร์ด จะเป็นการรับส่งข้อมูลแบบอนุกรม
ดังนั้น ต้องกำหนดค่าความเร็วของ Baud Rate หรือ Upload Speed ที่มีหน่วยเป็นจำนวนบิตต่อวินาที (bps) ให้ตรงกันด้วย
โดยปกติแล้ว ค่าความเร็วมาตรฐาน จะอยู่ที่ 9600 แต่ก็สามารถเลือกใช้ค่าความเร็วที่สูงกว่านี้ได้ เช่น 115200
หากเกินกว่านี้ การรับส่งข้อมูลอาจเกิดความผิดพลาดได้ง่าย
แต่เงื่อนไขที่สำคัญคือ ต้องกำหนดค่าความเร็ว ทั้งจากตัวโปรแกรมที่ระบุไว้ในโค้ดตรงบรรทัดคำสั่ง Serial.begin( ) และในหน้าต่าง Serial Monitor ให้ตรงกัน มิเช่นนั้น Serial Monitor จะไม่ทำงาน
รูปแบบการใช้คำสั่ง เพื่อดูข้อมูลที่ Serial Monitor มีดังนี้ ให้นักเรียน เขียนโค้ดตาม
จากนั้น เสียบสายเชื่อมต่อ ESP32 เข้ากับคอมพิวเตอร์ , เลือกบอร์ด , เลือกพอร์ท ให้เรียบร้อย
ทำการอัพโหลดโปรแกรมลงสู่บอร์ด
เมื่ออัพโหลดเสร็จแล้ว ให้คลิกที่มุมด้านบนขวา เพื่อเปิดหน้าต่าง Serial Monitor
จะปรากฎข้อความขึ้นมาบน Serial Monitor
ให้นักเรียนเขียนโค้ดเพิ่ม ดังนี้
จากนั้น อัพโหลดลงบอร์ด และเปิด Serial Monitor ดู จะมีข้อความขึ้นดังนี้ไหม
Hello Test. I am testing a Serial Monitor.
Value a = 10
Value b = 20
Value c = 30
จบบทเรียน
Google Sites
Report abuse
Page details
Page updated
Google Sites
Report abuse