บทความนี้เป็นการประยุกต์ใช้ DAC และ MicroPython ของไมโครคอนโทรลเลอร์ ESP32 เพื่อเปิดไฟล์ WAV ซึ่งเป็นไฟล์บันทึกเสียง และนำออกไปยัง DAC ที่เชื่อมต่อกับลำโพงดังภาพที่ 1 โดยไฟล์ที่นำมาใช้นั้นเป็นไฟล์แบบเสียงโมโน (mono) แบบ PCM 8 บิตที่ไม่ได้ถูกบีบอัด และโปรแกรมตัวอย่างรองรับการทำ Sampling Rate ที่ประมาณ 50KHz หรือที่ระดับ 44100
Read MoreCategory: Python
[EN] 15-Puzzle Game
This article is an example of a 15-Puzzle game using the ml4m board with the results shown in Figure 1. It is a game that allows players to practice their strategic thinking skills, looking ahead to plan their shifting numbers. In addition to being in the form of numbers, it can also be changed from numbers to images, that is, transformed into an image and divided into 16 parts, and then allow the player to move the image to make it the same as the original. Also in the example, a buzzer is used to generate a beep sound using an 8-bit DAC of an esp32 microcontroller, as well as programming in Python on MicroPython.
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.
Read More[EN] Tic-Tac-Toe
This article is a collection of examples of Tic-Tac-Toe games that our team uses to teach game development in different languages as appropriate for the group of learners. But most of them use Python for teaching because it is easier to explain and write than other languages. In addition to wanting to see how it can be implemented on other platforms, we used an example with the MicroPython of a board we named ml4m. Based on this board, TensorFlow Lite is installed on an ESP32 with a 4MB ROM. The board looks like Figure 1.
Read More[EN] List Class Application Node: Count the frequency from a random value.
This article is an application of Python’s list data structure to store the frequency count of random numbers which is useful for further statistical use. This article relies on knowledge of random numbers and using list type variables tested with Micropython on esp8266 and esp32 microcontrollers.
Read More[EN] DHT11 Web Report
This article is an application of Python programming for Micropython used with esp8266 or esp32 attached to DHT11 for temperature and humidity storage. The last 10 temperature results collected every 5 seconds are reported as shown in Figure 1.
Read More[EN] Python multi-threaded programming
This article discusses Python multi-threaded programming. Compiled from the website tutorialspoint.com (Make this article a memo). Running multiple threads is like running several different programs at the same time, but it’s useful:
- Each thread can share the memory with the main thread and can communicate with each other.
- Threads are smaller processes because they consume less memory than process calls.
[EN] PyGlet
pyglet is a Python library to create windows and cross-platform multimedia on Windows (Windows), MacOS (macOS) and Linux (Linux) for developing games or visualization applications. The library itself supports creating windows, integration with users through an event-based system, support OpenGL graphics, image/video loading support, and playing music. This article discusses installing and using pyglet on Raspberry Pi 3 B+ and Raspberry Pi 4 as a test device.
Read More[EN] ulab v3.0
From the previous ulab article, it was found that Micropython can implement the same dataset processing instructions as used in Numpy through the previous ulab library v.0.54.0 which is the older version of ulab (currently v.3.0.1) brought up this article. This article describes how to create a Micropython that integrates the ulab library and uses it with SPIRAM versions of esp32.
ulab3
From Figure 1, it can be seen that the structure of the ulab library has changed from the original. This causes the programming from the previous example to have to be modified. Under ulab there are libraries of numpy and scipy. The details of numpy that are supported are as follows.
Read More[TH] Simple MineSweeper
บทความนี้เป็นการทดลองสร้างเกม Simple MineSweeper ดังภาพที่ 1 ซึ่งใช้บอร์ดไมโครคอนโทรลเลอร์ ESP32 กับจอแสดงผล st7735 แบบ REDTAB ขนาด 1.8″ ความละเอียดของการแสดงผลเป็น 128×160 อันเป็นฮาร์ดแวร์เดียวกับเกม Simple Tetris [ตอนที่ 1, ตอนที่ 2 และตอนที่ 3] ที่ได้กล่าวไปก่อนหน้านี้ โดยยังคงใช้ MicroPython เป็นหลักเช่นเดิม และการอธิบายจะเริ่มเป็นขั้นตอน ๆ ไป จากสร้างหน้าจอ สุ่มค่า การนับค่า การควบคุมการเคลื่อนที่ การเลื่อนกรอบตัวเลือก การปิดไม่ให้เห็นข้อมูล การสร้างความสัมพันธ์ระหว่างการระบุว่าตำแหน่งใดน่าจะเป็นระเบิด การเลือกเปิด และการนับคะแนนเมื่อจบเกม
ตัวเกม Simple MineSweeper เป็นเกมแรก ๆ ที่พวกเราทำเลียนแบบเพื่อศึกษาวิธีคิดและพัฒนาเทคนิคการเขียนโปรแกรมมาตั้งแต่ยุคระบบปฏิบัติการ DOS และ Windows ที่เป็น GUI ของ DOS ซึ่งตอนนั้นเขียนและทำงานบนระบบปฏิบัติการ DOS พร้อมทั้งต้องเปลี่ยนโหมดเป็นกราฟิกส์โหมด ติดต่อกับเมาส์ และสั่งวาดพิกเซลเอง (จะว่าไปแล้วก็เหมือนกันกับการเขียนบนบอร์ดไมโครคอนโทรลเลอร์ ESP32 แหละครับ แต่ไม่มีระบบปฏิบัติการให้ใช้) … ว่าแล้วมาทดลองสร้างกันดีกว่าครับ ดูจะรำลึกอดีตกันเนิ่นนานเลยทีเดียว
Read More