Printing the Distance on LCD 5110 Screen

About: I am an Electric Electronic Engineer student . I want to share some projects with you

Hey everyone. Today , ı am ganna show you how can you measure the distance and print the distance on the screen.

Let's look steps...

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: PARTS

Here is a list of parts that i used to make this project:

  • Arduino UNO
  • HC04 Ultrasonic Sensor
  • Breadboard
  • Jumper Wires (male to male and male to female)
  • LCD5110 Display

Step 2: SCHEMA

Step 3: CODE

The code has explanations of code functions. You will easly understand it. If you have a problem , you can contact me.


LCD5110 lcd(8,9,10,11,12); //(clk,din,dc,rst,ce)

extern uint8_t MediumNumbers[]; //describe fonts extern uint8_t SmallFont[]; int echopin=6; //HC 04 ultrasonic sensor echopin int trigpin=5; //HC 04 ultrasonic sensor trigpin int BL=3; int TIME; //time int DISTANCE; //distance

void setup() { pinMode(echopin,INPUT); //echopin is ınput because it receives sound wave pinMode(trigpin,OUTPUT); //trigpin is output because it sends sound wave pinMode(BL,OUTPUT); //back light is output Serial.begin(9600); lcd.InitLCD(); //initilaze the lcd lcd.setContrast(55); //set contrast(0 to 125) }

void loop() { analogWrite(BL,300); digitalWrite(trigpin,LOW); //first, we start trigpin low delay(50); digitalWrite(trigpin,HIGH); //second, we open trigpin and send sound made delay(50); digitalWrite(trigpin,LOW); //then, we close again for other loop TIME = pulseIn(echopin,HIGH); //then, we open echopin and receive sound made //and measure the time with pulseIn() function. DISTANCE = sure/(2/29.1) ; //finally, we measure the distance

lcd.clrScr(); //clear screen lcd.drawRoundRect(0,0,70,43); //draw rectangle lcd.setFont(SmallFont); //set font lcd.print("DISTANCE",18,5); //print lcd.print("CM",40,30); //cm lcd.setFont(MediumNumbers); //set font lcd.printNumI(mesafe,2,22); //print distance delay(500); lcd.update(); //update }


Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest