[EN] Control movement from a joystick via WiFi with MicroPython.

This article is based on the article programming a client/server for a weather station over a wireless network or WiFi to modify from reading data from sensors to joystick shield (Arduino Joystick Shield) so that it has become a wireless game controller using MicroPython and an ESP32 microcontroller as shown in Figure 1. It is possible to control the movement of objects in the display via a ST7735 TFT screen connected to another ESP32. It will be found that the Python implementation of MicroPython is applicable in this example. And with an easy-to-write language and code that can be modified without recompiling and uploading, it’s easy to write prototype code for further development at a higher speed.

Control movement from a joystick via WiFi
(Figure. 1 Our board)
Read More

[EN] Collecting flags in a maze

This article is an example of writing a game. Move the character to walk in the maze to collect flags that are randomly positioned as shown in Figure 1, where the character will walk in the specified channel and can’t penetrate the wall. With a warning sound when trying to walk in an impossible location and when walking in any direction will change the image of the character to turn the face to that direction. In addition, pressing A will randomize the position of the new flag, pressing B will randomize the player’s position, and pressing D will exit the program. The board for use is still dCoreML4M as before, let’s get started.

(Figure. 1 The game in this article)
Read More

[EN] ESP32-ML4M : Tic-Tac-Toe Ep.2

From the article Tic-Tac-Toe games or OC games played with computers (esp32) via the console of the terminal program are inconvenient. Now let’s learn how to use the esp32 peripheral circuit of the ML4M board (Figure 1), how it has an I/O circuit and how is Tic-Tac-Toe game is played through the device in which the code works with the joystick module and touch switch.

(Figure. 1 ml4m for Tic-Tac-Toe testing)
Read More

[TH] Control movement from a joystick via WiFi with MicroPython.

บทความนี้เกิดจากการนำบทความการเขียนโปรแกรมไคลเอนต์/เซิร์ฟเวอร์สำหรับสถานีอากาศผ่านระบบเครือข่ายไร้สาย หรือ WiFi มาปรับเปลี่ยนจากการอ่านข้อมูลจากเซ็นเซอร์มาเป็นจอยสติกชิลด์ (Arduino Joystick Shield) เพื่อให้กลายเป็นเกมคอนโทรลเลอร์แบบไร้สายโดยใช้ MycroPython กับไมโครคอนโทรลเลอร์ ESP32 ดังภาพที่ 1 ทำให้สามารถควบคุมการเคลื่อนที่ของวัตถุในจอแสดงผลผ่านจอ TFT แบบ ST7735 ที่เชื่อมต่อกับ ESP32 อีกตัวหนึ่งได้ ซึ่งจะพบว่าการใช้งานภาษาไพธอนของ MicroPython นั้นสามารถนำมาใช้งานได้กับกรณีตัวอย่างนี้ และด้วยภาษาที่เขียนได้ง่ายประกอบกับสามารถปรับแก้โค้ดได้โดยไม่ต้องคอมไพล์และอัพโหลดใหม่จึงสะดวกต่อการเขียนโค้ดต้นแบบเพื่อนำไปพัฒนาให้มีความเร็วในการทำงานที่สูงขึ้นต่อไป

Control movement from a joystick via WiFi
ภาพที่ 1 อุปกรณ์การทดลองในบทความ
Read More

[TH] เกมวิ่งเก็บธงในเขาวงกต

บทความนี้เป็นตัวอย่างการเขียนเกมขยับตัวละครให้เดินไปในเขาวงกตเพื่อเก็บธงที่ถูกสุ่มตำแหน่ง ดังภาพที่ 1 ซึ่งตัวละครจะเดินในช่องที่กำหนดไม่สามารถทะลุกำแพงได้ โดยมีเสียงร้องเตือนเมื่อพยายามเดินไปในตำแหน่งที่ไม่สามารถไปได้ และเมื่อเดินไปทิศใดจะเปลี่ยนภาพของตัวละครให้หันไปทางทิศนั้น นอกจากนี้กำหนดให้การกดปุ่ม A ให้เป็นการสุ่มตำแหน่งของธงใหม่ การกดปุ่ม B ให้ทำการสุ่มตำแหน่งของผู้เล่น และถ้ากดปุ่ม D ให้ออกจากโปรแกรม โดยบอร์fสำหรับใช้งานยังคงเป็น dCoreML4M เช่นเดิม มาเริ่มกันครับ

ภาพที่ 1 ตัวอย่างเกมของบทความนี้
Read More

[TH] ESP32-ML4M กับเกม Tic-Tac-Toe ภาคจบ

จากบทความเกม Tic-Tac-Toe หรือเกมโอเอ็กซ์ที่เล่นกับคอมพิวเตอร์ (esp32) ผ่านทางคอนโซลของโปรแกรมเทอร์มินอลซึ่งไม่สะดวก คราวนี้มาเรียนรู้การใช้วงจรต่อพ่วงของ esp32 ของบอร์ด ML4M (ภาพที่ 1) ว่ามีวงจร I/O อย่างไรบ้าง และตัวอย่างเกม Tic-Tac-Toe ที่เล่นผ่านอุปกรณ์เป็นอย่างไร ซึ่งในโค้ดมีการทำงานกับโมดูลจอยสติก และสวิตช์แบบสัมผัส

ภาพที่ 1 บอร์ด ml4m บอร์ดทดสอบเกม Tic-Tac-Toe
Read More

[TH] Arduino: Joystick Module

บทความนี้เป็นการเขียนโปรแกรมเพื่อใช้งานโมดูลจอยสติก (Joystick) ดังภาพที่ 1 ซึ่งตัวโมดูลสามารถบอกข้อมูลการเคลื่อนที่ในแกน X การเคลื่อนที่ในแกน Y และสถานะการกดสวิทตช์ที่ตัวจอยสติก โดยตัวอย่างการใช้งานโมดูลนี้เป็นการใช้กับบอร์ด esp32 โดยใช้ภาษา C++ เพื่อเชื่อมต่อกับ GPIO ด้วยคำสั่งที่เคยกล่าวไปแล้วในบทความนี้

ภาพที่ 1 โมดูลจอยสติกกับ esp32
Read More