Introduction: Distance Finder Using ARM Cortex-M4

About: I'm Electrical Engineering Student, Coffee Lover, Automated System designer, Programmer and Security System Designer.

This is a breadboard based project which uses ARM Cortex-M4(Texas Instruments EK-TM4C123GXL) to find the distance using Ultrasonic Sensor. The output can be obtained in "cm" on both 16x2 LCD Screen and Serial Monitor of Energia IDE, Tera Team, Keil uVision or any other virtual terminal software.

We can also use 16x2 LCD Screen or Serial Monitor at the single time, means one thing is optional. During the measurement of distance, a RED LED of EK-TM4C123GXL shows the status of measurement and microcontroller. The whole circuit is powered by +5V (VBUS) and +3.3V of EK-TM4C123GXL..bin file of c99 code is attached with the provided link at the end of this tutorial. .bin file can be uploaded to the microcontroller using LM Flash Programmer.

Step 1: Requirements

The following things are required to get this project done:

1- Texas Instruments EK-TM4C123GXL

2- Potentiometer (eg 5K) (optional)

3- LCD 16x2 (optional)

4- Ultrasonic sensor

5- LM Flash Programmer (software on PC)

=> If you don't know how to use and install LM Flash Programmer, then please check out my previous Instructable, or click on the following links:

Downloading LM Flash Programmer

Upload .bin or .hex File Using LM Flash Programmer

Step 2: Pin-outs & Wiring

The Pin-outs & Wiring of ARM Cortex-M4 (Texas Instruments EK-TM4C123GXL) and other peripheral is attached with this step and also given following:





PB4 => RS


PE5 => E

PE4 => D4

PB1 => D5

PB0 => D6

PB5 => D7

+3.3V => A

GND => K


TM4C123GXL => Potentiometer


VBUS => 1st pin

GND => 3rd pin


Potentiometer => LCD


2nd pin => Vo

=> You can set contrast using Potentiometer


TM4C123GXL => Ultrasonic sensor



PA6 => Trig

PA5 => Echo


Step 3: Upload the .bin File

Upload the attached .bin file with this step to ARM Cortex-M4(Texas Instruments EK-TM4C123GXL) using LM Flash Programmer.

Step 4: Get Your Output

After uploading .bin file to ARM Cortex-M4(Texas Instruments EK-TM4C123GXL), you can get your output in "cm" on 16x2 LCD Screen or any of your desired terminal e.g. Energia IDE Serial Monitor, Keil uVision and Tera Team Virtual Terminal etc or both.