เริ่มต้นใช้งาน NodeMcu ESP8266 ด้วย Arduino IDE

5 Aug 2016,
Share: 

ในบทความที่แล้วเราได้ทําความรู้จักกับ ESP8266 กันแล้ว ในบทความนี้เราจะมาพูดถึงวิธีการใช้งาน ESP8266 ด้วย Arduino IDE โดยจะใช้ ภาษา c/c++ ในการเขียนโปรแกรม

ผมจะยกตัวอย่างการเพิ่มบอร์ด ESP8266 ใน Arduno IED และการเขียนโปรแกรมไฟกระพริบ โดยเครื่องมือที่ต้องใช้คือ

  • NodeMcu(ESP8266) ESP-12e
  • Arduino IDE

เริ่มแรกเปิดโปรแกรม Arduino IED และเลือกเมนู File—>Preferenes

Image

blink-led ในหน้าต่าง Preferences หัวข้อ additional Boards Manager URLs: ให้ใส่ “http://arduino.esp8266.com/stable/package\_esp8266com\_index.json” แล้วกดปุ่ม “ตกลง” ตามรูปด้านล่าง

Image

blink-led เลือกเมนู Tools—>Board:“xxxxx”—>Boards Manager…

Image

blink-led ในหน้าต่าง Boards Manager เลือก Type เป็น Contributed(หมายเลข 1) แล้วกด install esp8266 by ESP8266 Community

Image

blink-led รอจนติดตั้งเสร็จสิ้น

Image

blink-led ปิดโปรแกรม Arduino IDE แล้วเปิดขึ้นมาใหม่ จะเห็นวามี Board ESP8266 เพิ่มขึ้นมา ให้เลือกตาม Board ที่เราต้องการใช้งาน

Image

blink-led เสร็จสิ้นการติดตั้ง Board ESP8266 ต่อมาเรามาเขียนโปรแกรมแรกกัน คือโปรแกรม ไฟกระพริบ(Blink LED) เริ่มแรก เสียบ NodeMcu เข้ากับ Computer

Image

blink-led เข้าโปรแกรม Arduino IDE แล้วเปิดตัวอย่างโปรแกรมโดยเข้าที่ File—>Examples—>esp8266—>Blink

Image

blink-led จะพบกับตัวอย่าง Code ให้เรา compile(หมายเลข 1) แล้วโปรแกรมลง ESP8266(หมายเลข 2) ได้เลยครับ

Image

blink-led เมื่อโปรแกรมลง ESP8266 เสร็จแล้ว ไฟ LED บน board จะกระพริบ ดูวีดีโอตัวอย่างผลลัพธ์

Suggestion blogs

Configure the Linux Firewall for Docker Swarm on Ubuntu

บทความนี้จะเกี่ยวข้องกับการ Config Linux Firewall ให้สามารถใช้งาน Docker swarm ได้ ถ้าไม่ได้ Config เราจะเจอกับ Error นี้ "Timeout was reached before node was joined. The attempt to join the swarm will continue in the background. Use the "docker info" command to see the current swarm status of your node." ในขั้นตอนการ Join Swarm เพราะว่า Docker Swarm ใช้งาน port ดังต่อไปนี้

เรียนรู้ Extension Method

โดยปกติแล้ว Class ต่างๆจะมี Method เป็นของตัวเองอยู่แล้ว แต่ถ้าเราต้องการจะเขียน Method เพิ่มเติมเข้าไป ในกรณีที่เราเป็นเจ้าของ Source code เราสามารถแก้ไข Source code ของเราได้เลย แต่ถ้าในกรณีที่เราไม่ได้เป็นเจ้าของ Source code เรามีเพียงแค่ dll ไฟล์เท่านั้น เราจะทําอย่างไร? ใน .net 3.0 ขึ้นไป เราสามารถเพิ่ม Method เสริมให้กลับ Class ที่ถูกสร้างไว้แล้วได้ โดยจะเรียกว่า Extension Method

Flutter EP.4 Project structure file flutter

สวัสดีครับ ใน EP.3 เราได้เรียนรู้ Widget ใน Flutter กันไปแล้ว สําหรับเนื้อหาต่อไปในบทความนี้จะเป็นเรื่องโครงสร้างไฟล์ใน Flutter ว่ามีอะไรบ้าง แต่ละไฟล์คืออะไร เราจะได้มาเรียนรู้กันครับ


Copyright © 2019 - 2025 thiti.dev |  v1.58.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ