PING With Two 7 Segment LED Displays.

About: 18 y/o guy with huge ambitions

Intro: PING With Two 7 Segment LED Displays.

Hello Guys!
moxigen here. I got two new 7 segment LED displays, and I was pretty much excited to use them. I decided to multiplex them and use them with parallax ping(HC-SR04).

Step 1: Materials Required

You would require the following:

1. 2 x 7 Segment LED displays(common cathode)

2. 1 x HC-SR04 distance sensor (four pin)

3. Arduino Mega 2560( or any prototype)

4. small breadboard

5. Jumper Wires

Step 2: Assemble It!

remember that you're gonna have to multiplex the two displays, so use normal wires( no matter if they're naked, just make sure they don't touch each other) to connect the two displays and finally to the Arduino.
And I'm really sorry for the untidiness in the drawings.

Step 3: The Code

#include "SevSeg.h" 

SevSeg sevseg; 

int refreshTime = 1000;
int pingPin = 14; //10 
int inPin = 15; //9 
long duration, inches, cm;
int indec, cmdec;
int inchconv = 147; 
int cmconv = 59; 
unsigned long timer;

void setup() {
  pinMode(pingPin, OUTPUT);
  pinMode(inPin, INPUT);

void loop()
    digitalWrite(pingPin, LOW);
  digitalWrite(pingPin, HIGH);
  digitalWrite(pingPin, LOW);
  duration = pulseIn(inPin, HIGH);
    inches = microsecondsToInches(duration);
  indec = (duration - inches * inchconv) * 10 / inchconv;
  cm = microsecondsToCentimeters(duration);
  cmdec = (duration - cm * cmconv) * 10 / cmconv;
  unsigned long mils=millis(); 
if (mils-timer>=refreshTime) { 

sevseg.NewNum(cm,(byte) 2); 

long microsecondsToInches(long microseconds)
  return microseconds / inchconv;

long microsecondsToCentimeters(long microseconds)
  return microseconds / cmconv;

Step 4: Acknowledgements

Thank you to ya all for viewing this instructable. I'm really open to criticism, so feel free to comment.

please follow my Instagram account if possible: moxigen.



    • Tiny Home Contest

      Tiny Home Contest
    • Metalworking Contest

      Metalworking Contest
    • Audio Contest 2018

      Audio Contest 2018

    3 Discussions


    10 months ago

    how to connect to arduino?


    3 years ago on Introduction

    OK, so where are the code?

    I mean, I don't exactly need a code.

    But I don't know how to use the multiplexed 7 segment to display different digits on different displays?

    1 reply

    Reply 3 years ago

    Dude I am so sorry I didn't upload code however I edited it and you can have a look at it now