Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Based Ultrasonic Distance Measurement with TM1637 Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Ultrasonic Distance Measurement with TM1637 Display

Circuit Documentation

Summary

This circuit integrates an Arduino UNO microcontroller with a JSN-SR04T ultrasonic sensor and a TM1637 4-digit 7-segment display. The purpose of the circuit is to measure distances using the ultrasonic sensor and display the measured values on the TM1637 display. The Arduino UNO serves as the central processing unit, controlling the sensor to perform distance measurements and driving the display to show the results.

Component List

Arduino UNO

JSN-SR04T Sensor

TM1637

Wiring Details

Arduino UNO

JSN-SR04T Sensor

TM1637

Documented Code

#include "NewPing.h"
#include "TM1637Display.h"

// Display
const int clkPin = 3; // CLK pin connected to TM1637
const int dioPin = 4; // DIO pin connected to TM1637

// Sonar
const int trigPin = 12; // TRIG pin connected to JSN-SR04T Sensor
const int echoPin = 11; // ECHO pin connected to JSN-SR04T Sensor
const int maxDist = 450; // Maximum distance to measure

NewPing sonar(trigPin, echoPin, maxDist); // Initialize sonar object
TM1637Display display(clkPin, dioPin); // Initialize display object

void setup() {
  Serial.begin(115200); // Start serial communication at 115200 baud
  display.setBrightness(5); // Set display brightness
}

void loop() {
  long distance = sonar.ping_cm(); // Measure distance in centimeters
  Serial.print("Distance:"); // Print distance to serial monitor
  Serial.println(distance);
  display.showNumberDec(distance); // Display distance on TM1637
  delay(200); // Wait for 200 milliseconds
}

This code initializes the ultrasonic sensor and the display, then continuously measures the distance and displays it on the TM1637. The serial monitor also outputs the distance for debugging purposes. The NewPing library is used for easy interfacing with the ultrasonic sensor, and the TM1637Display library is used to control the 7-segment display.