Ultrasonic Rangefinder | MindPlus Coding Kit for Arduino Started Tutorial E14

0 4087 Easy

Chapter 6 Real-Time Test Device

Project 1 Ultrasonic Rangefinder

We already learnt how ultrasonic ranging works in the making of nearsightness alert In this section, we will learn to use an electronic screen to display the ultrasonic ranging results more intuitively.

Task Navigation

Learn about IIC LCD

Making an ultrasonic rangefinder

Key Points Analysis

IIC-1602 LCD Display

1.Up to 16 characters per line, two lines in total.

2.Clear the screen before output in case of garbled texts.


We deal with VCC a GND everyday, but what are SCL and SDA?

First of all, we must know that IIC is a bus structure. Generally, there are two signal lines, one is the clock line SCL, and the other is the bidirectional data line SDA. SCL is called the clock line and SDA is called data line. Among all buses, IIC bus uses the least signal lines and has the most functions.

Therefore, IIC bus is very convenient and flexible when used to design a computer system. It is also small and can be widely applied. That’s what we need to know for now. We will learn more as we explore the programming world.

To use this module, you need to select the corresponding IIC address for initialization.

Command List



Hardware connection


(Note the wire matching and relative positions)


1. Write the program

1) Click "Extensions" in Mind+ and select LCD1602 in "Monitors":


2) Initialize IIC address:


3) Generally, the IIC address of this screen is 0x3E. For any special cases, we can click "Extensions" to select "IIC functional address scan" in "Function modules" to load the building block to scan the current IIC device device address.


When more than one IIC address is scanned, it means that a device with IIC is embedded in the device, then we need to try one by one until the screen is lit up.

2. Reference program


3. Program results

The screen lights up and the ranging results are output in real time.


P.S. Currently it only supports English display.

4. Program analysis


Further Reading

Display screens are used in all aspects of our lives, such as mobile phones, home televisions, home appliances, calculators, computers, and other devices we use every day. There are many types of screens. And even LCD has many sub-types. Also, we have the new OLED flexible displays, miniLED displays, and microLED displays. So, what are the types of displays and how are they defined?

1) Seven-Segment Displays

Seven-Segment Display was invented by Japanese and was introduced into China in 1980s. It was used to replace LED digital tubes (consisting 7 segments for displaying numbers 0-9) in calculators and clocks. They can only display numbers and are simple in structure.

There are many alternative names too: segment LCD, small-sized LCD, “8” display, pattern LCD and others.

2) Matrix Displays

Matrix displays are divided into LCD matrices and LED matrices. In simple terms, matrix displays are many dots arranged together, which are called pixels. LCD matrix displays consist of dots arranged in an array. For example, 12864 display consist of 128 dots horizontally and 64 vertically.

3) TFT color display

TFT is a type of LCD, and is the prototype of all current improved LCD displays. They were installed on old mobile phones. It is also a matrix display with pixels, where the color is the concept of color levels. Color level is an index standard reflecting the brightness of the LCD screen, commonly referred to as the color index. There are generally three color qualities commonly seen on the market today: 256 colors, 4096 colors, and 64K (i.e., 65536) colors and even higher 260k colors. Display quality varies with different color qualities. They can display three kinds of content: general text, simple images (like cartoons, which are mainly used for menu items and standby screens), and photo images. As for users with higher requirements for photo quality, 64K color is certainly a better choice.

1) LED Displays

LED display is a simple concept. It is made of many LED lights. The shop signs we see everywhere are LED displays.

2) OLED Displays

OLED displays display images by self-emitting pixels. From this perspective, the technology of OLED screens is more advanced than that of LCD screens. In addition, the OLED screen can be made thinner, beneficial to the dimension utilization of the device.

Generally speaking, most displays are either LCD or OLED. There is an essential difference in how the light is emitted by two kinds of displays. One uses external light source while the other one is self-luminous. From a current perspective, two camps will continue to divide as different users have different needs for color performance.

3) miniLED Displays

miniLED, also known as "sub-millimeter light emitting diode", is an LED with a size of about 100 microns first proposed by Epistar. miniLED is a transitional technology between traditional LED and micro LED. It is an improved version of traditional LED backlight.

4) MicroLED Displays

The microLED screen is a new generation display technology with a matrix of miniaturized LEDs. In short, LED backlights are thinner and more compact, and LED units are smaller than 100 microns. Like OLEDs, each pixel is individually addressed and driven to emit light (self-emitting).

Further Exercise

Besides simple numbers display, we are also seeing coordinates commands in the building blocks loaded by the display. Think what else we can do with IIC LCD?

icon Program 6-1 E14.rar 165KB Download(4)
All Rights