In this tutorial, we will learn how to use an ultrasonic sensor to measure distance and display the resulting values on a TFT Display. You can modify this project to make a self driving car.
If an object’s position is constantly changing, measuring its distance from you can be a challenging task. However, one potential solution to this problem is to use an ultrasonic sensor.
Connect the wires between the TFT Display and the Arduino and the ultrasonic sensor as shown in the image below.
Connections from the Arduino to the breadboard:
• Arduino GND pin → Breadboard ground line
• Arduino 5V pin → Breadboard 5V line
Connections from the Arduino to the ultrasonic sensor:
• Arduino pin 3 → ultrasonic sensor Trig pin
• Arduino pin 2 → ultrasonic sensor Echo pin
Connections from the ultrasonic sensor to the breadboard:
• ultrasonic sensor VCC pin → Breadboard 5V line
• ultrasonic sensor GND pin → Breadboard ground line
Connections from the TFT Display to the breadboard:
• TFT Display VCC pin → Breadboard 5V line
• TFT Display GND pin → Breadboard ground line
• TFT Display LED pin → Breadboard 5V line
Connections from the l298n motor driver to arduino :
• TFT Display CS pin → Arduino pin 10
• TFT Display RST pin → Arduino pin 8
• TFT Display DC pin → Arduino pin 9
• TFT Display MOSI pin → Arduino pin 11
• TFT Display SCK pin → Arduino pin 13
• TFT Display MISO pin → Arduino pin 12
Once you’ve uploaded the code to the Arduino board, you will find that the TFT Display displays the distance value as shown in the GIF below.