[EN] Binary Search Tree

This article is about programming C/C++ language with Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C] and ET-BASE AVR EASY32U4 (Figure 1) or other boards and platforms using C language for learning to code another type of data structure management program that has different storage and management methods, called BST or Binary Search Tree, as in Figure 2, which is a structure that can be applied to collecting data with attributes in which the data on the left node is less than current node and the right node is greater than current node or the opposite, the left node is greater and the right noe is less. Thus, searching for data in the event that the tree is balanced both left and right on the BST structure saves time or number of searches per round by half of available data, for example, there are 100 data sets in the first round, if the current node is not what you’re looking for it, the choice left is to find from the left or right node. This selection causes the data of the other side to be ignored or cut it in half approximately but if the Binary Search Tree is unbalanced, the search speed will not be much different from the Sequential Search.

ET-BASE AVR EASY32U4
Figure 1 ET-BASE AVR EASY32U4
Read More

[EN] Doubly Linked-List

This article is about programming C/C++ language with Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C], ET-BASE AVR EASY32U4 or other boards and platforms that use C language to store temperature/humidity data from the DHT11 sensor (Figure 1) with a dual linked list data structure. The basics of memory reservation, access, memory deallocation can be read in the previous article (Singly Linked List).

Figure 1 Arduino Uno and DHT11
Read More

[TH] Binary Search Tree

บทความนี้เป็นการเขียนโปรแกรมภาษา C/C++ กับบอร์ด Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C] และ ET-BASE AVR EASY32U4 (ภาพที่ 1) หรือบอร์ดอื่น ๆ และแพล็ตฟอร์มอื่น ๆ ที่ใช้ภาษา C เพื่อเรียนรู้การเขียนโปรแกรมจัดการโครงสร้างข้อมูล (Data Structure) อีกประเภทหนึ่งซึ่งมีวิธีการจัดเก็บและจัดการที่แตกต่างกันไปอันมีชื่อว่าต้นไม้แบบ BST หรือ Binary Search Tree ดังในภาพที่ 2 ซึ่งเป็นโครงสร้างที่สามารถนำไปประยุกต์เกี่ยวกับการเก็บข้อมูลที่มีคุณลักษณะที่ข้อมูลทางกิ่งด้านซ้ายมีค่าที่น้อยกว่าตัวเอง และกิ่งด้านขวามีค่ามากกว่าต้นเอง หรือทำตรงกันข้ามคือกิ่งซ้ายมีค่ามากกว่า และกิ่งด้านขวามีค่าน้อยกว่า ทำให้การค้นหาข้อมูลในกรณีที่ต้นไม้มีความสมดุลย์ทั้งทางซ้ายและทางขวาบนโครงสร้าง BST ประหยัดเวลาหรือจำนวนครั้งในการค้นหาลงรอบละครึ่งหนึ่งของข้อมูลที่มี เช่น มีข้อมูล 100 ชุด ในรอบแรกถ้าตัวเองยังไม่ใช่ข้อมูลที่กำลังค้นหา จะเหลือทางเลือกให้หาจากกิ่งทางซ้ายหรือขวา ซึ่งการเลือกทำให้ข้อมูลของอีกฝั่งนั้นไม่ถูกพิจารณา หรือตัดทิ้งไปครึ่งหนึ่งโดยประมาณ แต่ถ้าเป็นกรณีที่ Binary Search Tree นั้นขาดความสมดุลย์จะส่งผลให้การค้นหามีความเร็วไม่แตกต่างกับการค้นหาแบบลำดับ (Sequential Search) เท่าใดนัก

ET-BASE AVR EASY32U4
ภาพที่ 1 บอร์ด ET-BASE AVR EASY32U4
Read More

[TH] Doubly Linked-List

บทความนี้เป็นการเขียนโปรแกรมภาษา C/C++ กับบอร์ด กับบอร์ด Arduino Nano, Arduino Uno, LGT8F328P [NANO F328P-C] และ ET-BASE AVR EASY32U4 หรือบอร์ดอื่น ๆ และแพล็ตฟอร์มอื่น ๆ ที่ใช้ภาษา C เพื่อจัดเก็บข้อมูลอุณหภูมิ/ความชื้นจากเซ็นเซอร์ DHT11 (ดังภาพที่ 1) ด้วยโครงสร้างข้อมูลแบบลิงค์ลิสต์คู่ โดยพื้นฐานของการจองหน่วยความจำ การเข้าถึง การยกเลิกการจองหน่วยความจำสามารถอ่านได้จากบทความก่อนหน้านี้ (Singly Linked List)

ภาพที่ 1 บอร์ด Arduino Uno และเซ็นเซอร์ DHT11
Read More

[EN] Queue data structure with array and Singly Linked List.

This article describes Queue Data Structures previously written in the Python Queue Data Structure article and is frequently used with the MicroPython example, but this article is written in C via Arduino IDE to use with microcontroller board LGT8F328P, SAM-D21, ESP8266, ESP32 and ESP32-S2 as shown in Figure 1 by using an example of the array structure and a single link list as a queued data structure. This article is probably the last article on JarutEx.

Figure 1 ESP32-S2, LGY8P326P and SAM-D21
Read More

[EN] Draw an analog clock using MicroPython.

The previous article discussed how to improve the display speed by using the double buffer technique. It is applied for the analog clock display as shown in Figure 1. We used Trigonometric calculations to determine the coordinates (x,y) of the tips of the seconds, minutes and hours. Each second operation uses a timer to make the operation closer to real-time than the Loop or Delay.

Figure 1 Result of drawing Analog clock
Read More

[EN] Binary Search Tree data structure programming with Python.

In the previous article, programming to implement queue-based data structures was introduced. In this article, we introduce programming to manage another type of data structure which has different storage and management methods called BST tree or Binary Search Tree, as shown in Figure 1, which is a structure that can be applied to data collection with attributes in which the data in the left branch is less than itself and the right branch is greater than itself or the opposite, i.e. the left branch has a greater value and the right branch is less. It enables searching for data in cases where the tree is balanced on the left and right in the BST structure, saving half the time or number of search times per round of available data, e.g. 100 data sets in the first round if it is not the information you are looking for will be left with a choice to find from the left or right branches which the selection causes the information of the other side is not considered or cut off approximately half. However, if the Binary Search Tree is out of balance, the search speed is not much different from the sequential search.

In this article, we use Python that works on either a Python 3 or MicroPython interpreter to store the data, adding information ,searching for information as an example of further development.

BST : Binary Search Tree
Figure 1 BST
Read More

[TH] Queue data structure with array and Singly Linked List.

บทความนี้เป็นการอธิบายเกี่ยวกับโครงสร้างข้อมูลแบบคิว (Queue) ซึ่งได้เคยเขียนถึงไปในบทความ Queue Data Structure ที่เป็นภาษาไพธอนและถูกนำไปใช้บ่อยกับตัวอย่างของ MicroPython แต่บทความนี้เป็นภาษา C ที่เขียนผ่าน Arduino IDE เพื่อใช้งานกับบอร์ดไมโครคอนโทรลเลอร์ LGT8F328P, SAM-D21, ESP8266, ESP32 และ ESP32-S2 ดังภาพที่ 1 โดยยกตัวอย่างการนำโครงสร้างแถวลำดับ และลิงค์ลิสต์เดี่ยวมาเป็นโครงสร้างข้อมูลแบบคิว และคงเป็นบทความสุดท้ายบน JarutEx แล้วครับ

ภาพที่ 1 บอร์ดไมโครคอนโทรลเลอร์ ESP32-S2, LGY8P326P และ SAM-D21
Read More

[EN] Understand and use the ESP32-C3

We have been using the esp8266, especially the esp-01 and esp-01s modules, to manage the sensor network for quite some time and with the limitation in terms of the number of pins used, the system must be designed to work with STM32F103C8T6 or STM32F401CCU6/STM32F411CEU6. To ensure stable operation, no problems with the esp8266’s WDT were encountered, and over time, espressif released several other microcontrollers such as esp32, esp32-s2, esp32-c3 and esp32-s3.

We have tested and used esp32 almost all the time until esp32-s2 with LILYGO board made us try to order it. The main problem is that the development tools are very late. However, as of now, espressif has released a development kit for Arduino or Arduino Core for ESP32 version 2.0 with support for esp32 esp32-s2 and esp32c3, making it work with ESP32 and ESP32-S2. We got the esp-c3-32s board so this article was born.

This article is compiled from the datasheet of ESP32-C3 WROOM-02, in this article we use the board as shown in Figure 1. The example program is to drive an RGB LED on the board to work by using Arduino Core for ESP32 and the improved ESP-IDF from the article in Ep. 3

(Figure. 1 ESP32-C3)
Read More