divya_kadava
Published © GPL3+

Safe Distance Alert Using Bolt IoT

The vehicles at present aren't smart. It sounds cool if it alerts when the vehicle comes close to others.

BeginnerFull instructions provided30 minutes3
Safe Distance Alert Using Bolt IoT

Things used in this project

Story

Read more

Schematics

Safe Distance Alert Breadboard Circuit

The circuit for the Safe Distance Alert system

Code

Safe Distance Alert

Arduino
This is the Arduino code which you can run on Arduino software. It checks the distance against threshold and alerts.
#include <BoltDeviceCredentials.h>
#include <BoltIoT-Arduino-Helper.h>
const int trigpin=9;
const int echopin=10;
const int buzzer=11;
const int ledpin=13;
long duration;
int distance;
int safetydistance;

void setup() {
  pinMode(trigpin,OUTPUT);
  pinMode(echopin,INPUT);
  pinMode(buzzer,OUTPUT);
  pinMode(ledpin,OUTPUT);
  Serial.begin(9600);
  

}

void loop() {
  digitalWrite(trigpin,LOW);
  delayMicroseconds(2);
  digitalWrite(trigpin,HIGH);
  delayMicroseconds(10);
  digitalWrite(trigpin,LOW);
  duration=pulseIn(echopin,HIGH);
  distance=duration*0.034/2;
  safetydistance=distance;
  if(safetydistance<=5){
    digitalWrite(buzzer,HIGH);
    digitalWrite(ledpin,HIGH);
  }
  else{
    digitalWrite(buzzer,LOW);
    digitalWrite(ledpin,LOW);
  }
  Serial.print("Distance:");
  Serial.println("distance");

}

Credits

divya_kadava

divya_kadava

1 project • 0 followers
currently, I am studying Btech. I have been working for since 1 year and having interest to learn technology i was started in hardware

Comments