Introduction: 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.

Coded Creations

Participated in the
Coded Creations