Interfacing Microbit with Large Screens (Serial Screens)

Interfacing Microbit with Large Screens (Serial Screens)

A few days ago, a Microbit user was discussing how to control a larger screen with Microbit, or to control a touch screen directly. Is there a simple method? Yes! Today, I will tell you!

Most of the conventional display controls for Microbit have been written by enthusiastic teachers, and everyone has been using them. Special thanks to teachers Shao Ziyang and Lv Qigang for their detailed tutorials Interfacing Microbit with Large Screens (Serial Screens). As far as I know, Microbit can now control 4-digit digital tubes, I2C 1602 LCD screens, I2C OLED screens, and 8×8 dot matrix screens. If there are any other screens not mentioned, please let me know in the comments Interfacing Microbit with Large Screens (Serial Screens).

Since there are already tutorials for conventional screens, today I will write about a larger screen, which is a common serial screen (with touch function) on the market. If you like this article, remember to leave a comment or share it, so I can have more funds to buy fun things for Microbit, thank you Interfacing Microbit with Large Screens (Serial Screens)~## What is a Serial Screen It is a highly integrated screen designed to simplify screen development. Generally, the screen integrates a powerful microcontroller to independently handle screen events and communication. It usually communicates with other main control boards through serial protocols to interact with the screen. This type of serial screen is generally paired with a user-friendly graphical development interface on the PC side to reduce development difficulty. Manufacturers, please pay advertising fees if you see this~

Interfacing Microbit with Large Screens (Serial Screens)

## Microbit Control Serial Screen Ideas Let’s outline the ideas so that we can learn with purpose. As long as we tackle the knowledge points one by one, we can easily achieve the expected results.

Interfacing Microbit with Large Screens (Serial Screens)

Don’t be afraid of serial communication; it is the most common protocol in microcontroller control. You just need to remember this. Due to space constraints, this tutorial will only cover triggering serial commands from the serial screen and receiving serial commands on Microbit to execute programs (the most common use of serial screens). ## A Little Try – Microbit Serial Sending Do you remember the offline version of Makecode produced by our family? The most loved feature besides being offline is the powerful serial printing function, right? This serial printing function is used to transmit the values detected by the Microbit’s sensors to the computer via the USB serial port, which is most suitable for ultrasonic distance detection and simulating sensor detection. Some people may ask, isn’t it possible to display values on the dot matrix screen of Microbit? I tell you, the display on the Microbit dot matrix screen is too slow, especially for three digits or more, it takes a long time to scroll the complete number. For real-time detected data, serial printing can present a trend through graphical curves, which is very convenient. Serial communication is very simple, and I hope you will use it more often.

Interfacing Microbit with Large Screens (Serial Screens)

After downloading the program, the data returned from serial printing will be displayed. Remember to select “Display Data Device” and not “Simulator” to see the serial data returned by Microbit.

Interfacing Microbit with Large Screens (Serial Screens)

## Microbit Serial Receiving Program If you have previously used the 2.4g receiving signal program of Microbit, then the following serial receiving program will be easy to understand. First, when powered on, the serial port is initialized. There are two ways to initialize the serial port: 1. One way is to redirect to USB, generally used for direct communication between Microbit and the computer. 2. The other way is to redirect to two pins on the Microbit, generally used for communication between Microbit and other serial circuit boards. When serial data is received (usually ending with a newline character)

the read string is stored as a variable, and then a conditional statement is used to check if the variable is equal to a threshold value, triggering the control action of Microbit accordingly. Text operations may be a bit unfamiliar, but with practice, everyone can master it. What? You ask why can’t we directly compare variable a, but must use text operations? Because the data “read from the serial port” contains a newline character. For example, “ab newline character” and “ab” will never be equal, I was stuck here for a long time, only after experimenting did I realize that “reading from the serial port” contains a newline character!! Oh dear~ I was stuck here for a long time, thinking it was natural to only have “ab”! What a conspiracy!~

Interfacing Microbit with Large Screens (Serial Screens)

After completing this program, download it to the Microbit board. The following preparation will be used. ## Verify if our Serial Receiving Program is Correct The program is already written, and we need to send serial data to Microbit to see if it can receive the correct data and trigger the desired effect. So what tool do we use to send serial data to Microbit? Well, since Microbit can send data through water~ it can also send data to the computer via serial. Alright, I want to recommend a very handy serial debugging software created by the Arduino Chinese community, thank you very much, and please remember to pay the advertising fee if you see this. Recommended for its simple Chinese interface, no installation required… and customizable button sending instruction function, enough for ordinary users (okay, saying it’s good is looked down upon by programmers~)

Interfacing Microbit with Large Screens (Serial Screens)

Interfacing Microbit with Large Screens (Serial Screens)

## Verification Start First, you need to ensure that you have installed the serial driver for Microbit. If you have not installed it or do not know what a serial driver is, please search the keyword “serial driver” in the cat’s forum. When you connect Microbit to the computer via USB, open this serial software, and you will find a COM port other than COM1, the specific number may vary for each computer, assigned by the computer’s preferences (funny face). For example, here it shows: COM64

Interfacing Microbit with Large Screens (Serial Screens)

You will also need to set the baud rate, which is the communication speed. Don’t ask me why it is 115200, the USB serial communication speed for Microbit is 115200. Finally, click to open the serial port

Interfacing Microbit with Large Screens (Serial Screens)

The serial port has been successfully opened, and the “bridge” for communication between the computer and Microbit has been established.

Interfacing Microbit with Large Screens (Serial Screens)

We try to send the command ab + newline (enter), in the sending area, type ab and then press the enter key, and click the send button. As shown in the animation below

Interfacing Microbit with Large Screens (Serial Screens)

## Experimental Results

Interfacing Microbit with Large Screens (Serial Screens)

OK~ The experiment was successful, the key is to make sure to press enter (newline character) after typing ab, then click send, otherwise you only sent ab, and the Microbit’s serial detection program will not be triggered. Let’s test cd, press enter, and then click send. If a crying face appears, it means the program is written correctly. If you do not get the expected experimental phenomenon, there may be several reasons: 1. The Microbit program is wrong 2. The serial software operation is incorrect 3. The wrong serial port is selected? ## Buying a Serial Screen I bought this one, which has touch functionality. Purchase the screen size according to your needs; generally, the larger the screen, the more expensive it is. Regardless of the size of the screen, the software used and the programming method are the same; only the images for the interface need to be larger. A teacher once told me about a project with students; previously, they used a small 1602 screen to save costs, but it did not create much impact. Later they used a 7-inch touch screen and surprisingly made it to television (funny face). Large touch screen interactions really add value to the project, so purchase accordingly, and the touch function is essential; the screen size does not matter. There are other serial screens on the market that may have better cost performance, but due to budget constraints, I just randomly picked a serial screen that a friend had used on a 3D printer. If you mention my name, the store owner will give you a discount~

Interfacing Microbit with Large Screens (Serial Screens)

After purchasing, download the materials and install the software. First, learn how to create the interface according to the video tutorial.

Interfacing Microbit with Large Screens (Serial Screens)

The pit I have already leveled, the only pit is that their software has been upgraded, but the tutorial has not been updated. So first create a font library (jump to the video at 8 minutes and 20 seconds to learn how to create a font library), otherwise the software compilation will report an error.

Interfacing Microbit with Large Screens (Serial Screens)

If the font library is not added, the compilation will report an error as below.

Interfacing Microbit with Large Screens (Serial Screens)

## Serial Screen Programming First, prepare the image materials. I used my clumsy image editing skills to create two pictures sized 400×240, which exactly correspond to the size of the screen I purchased.

Interfacing Microbit with Large Screens (Serial Screens)

Interfacing Microbit with Large Screens (Serial Screens)

Then, follow the video tutorial for the serial screen for all operations. The materials are the smiley and crying faces shown above, and create two trigger buttons according to the tutorial. The only difference from the tutorial is that we need to send the corresponding control instructions to Microbit when the button is triggered: “ab enter” and “cd enter”. The operation is very simple: in the button event section, we add code, such as for button b0’s button event: prints “ab”, 0printh 0aInterfacing Microbit with Large Screens (Serial Screens)

Button b1’s button event

Interfacing Microbit with Large Screens (Serial Screens)

Alright~ After setting up the UI and the program, we compile, debug, and test it, and the simulation function is really nice~ If everything is fine, download it to the serial screen.

Interfacing Microbit with Large Screens (Serial Screens)

## Connecting Serial Screen with Robotbit There is no difficulty in connecting; just connect the corresponding pins correctly. Please double-check the wiring before powering on, otherwise, I will not lend you a shoulder if you burn the screen~

Interfacing Microbit with Large Screens (Serial Screens)

## Microbit Program Modification Previously, the Microbit program used USB as the serial communication interface; now we need to redirect the serial to P1 and P2 according to our connection shown above.

Re-download the program to Microbit

Interfacing Microbit with Large Screens (Serial Screens)

## Result Phenomenon Turn on the power switch of Micorbit, and OK~

Interfacing Microbit with Large Screens (Serial Screens)

The most common method we use is this: after writing the main control board’s serial information monitoring program, the screen interaction sends instructions to the main control board. Then, the main control board controls other electronic modules. As for how Microbit sends data to the serial screen, we will discuss it next time when we have time, for fear that the article is too long and everyone will doze off. ## Big PackageMicrobit program Corresponding serial screen program Serial screen materials Serial tools will be compiled into a compressed package later, please visit the cat’s forum to download~ Search the keyword “serial screen” www.kittenbot.cn/bbs

Leave a Comment

×