Showing posts with label smart distance meter. Show all posts
Showing posts with label smart distance meter. Show all posts

Sunday, April 10, 2022

Arduino Based Smart Distance Meter


 Arduino Based Smart Distance Meter









COMPONENT'S FOR THIS PROJECT'S

· ARDUINO NANO

· ARDUINO NANO SERIAL USB CABEL

· ULTRASONIC SENSOR (HC-SR04) 

· OLED DISPLAY

· BREAD-BOARD

· JUMPER WIRES

· BATTERY (optional) you can also use by usb cabel power supply

SOFTWARE & APPLICATION

· ARDUINO IDE

https://www.arduino.cc/en/software


CIRCUIT DIAGRAM









ARDUINO CODE'S


#include <SPI.h>

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

 

#define trigPin 9

#define echoPin 8

 

#define OLED_RESET 4

Adafruit_SSD1306 display(OLED_RESET);

 

void setup() {

Serial.begin (9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

display.begin(SSD1306_SWITCHCAPVCC, 0x3C); //initialize with the I2C addr 0x3C (128x64)

display.clearDisplay();

 

}

 

void loop() {

float duration;

float distance_cm;

float distance_in;

 

digitalWrite(trigPin, LOW); //PULSE ___|---|___

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

 

duration = pulseIn(echoPin, HIGH);

 

distance_cm = (duration/2) / 29.1;

distance_in = (duration/2) / 73.914;

 

display.setCursor(30,0); //oled display

display.setTextSize(1);

display.setTextColor(WHITE);

display.println("Distance Meter");

 

display.setCursor(10,18); //oled display

display.setTextSize(2);

display.setTextColor(WHITE);

display.println(distance_cm);

display.setCursor(90,18);

display.setTextSize(2);

display.println("cm");

 

display.setCursor(10,45); //oled display

display.setTextSize(2);

display.setTextColor(WHITE);

display.println(distance_in);

display.setCursor(90,45);

display.setTextSize(2);

display.println("in");

display.display();

 

delay(1000);

display.clearDisplay();

 

Serial.println(distance_cm);

Serial.println(distance_in);

}


YOUTUBE VIDEO LINK


https://youtube.com/shorts/bYwQIT8mi_Q?feature=share



Smart Snapchat Card

  Smart Snapchat Social Media Card Seamless Connections: Adding the Smart Snapchat Card with a Scan or a Simple Hold. Introduction: In the r...