This project measure distance using the popular ultrasonic sensor and print the value in cm on the TM1637 seven segment

This project measures distance in cm using the ultrasonic sensor and displays readings on the popular TM1637 seven segment display module.

Introduction

This is a project that can be modified by introducing an alarm system so that the device can serve as obstacle alert for the blind. The project measures distance up to about 400cm and can be used in Robots as obstacles avoidance sensor. The project is designed using the cloudx priscilla mini board which has a memory of about 64kB and uses the Microchip Technology Processor PIC18F2620.

ultrasonic2.jpg
        // Your code here
#include <CloudX\Ultrasonic.h>
#include <CloudX\Segment_TM1637.h>
#include <CloudX\Ultrasonic.h>

#define trig 5
#define echo 6

#define clk 1
#define dio 2


int distance;
setup(){
           //setup here
           SegmentTM1637_setting(dio, clk, 5);
           Ultrasonic_init(1,trig,echo);
           SegmentTM1637_write(0);

loop(){
           //Program here
          distance = Ultrasonic_read(1); //returns value in cm
          SegmentTM1637_write(distance); 
          delay(100);
      }
}
    
Olayiwola Ayinde
An Embedded System Programmer, Robotic Engineer, a Maker, Co-Founder and CTO ByteHub Embedded, Inventor of CloudX, Tech Instructor and Educationist.

Categories