Random Stuff We Make!Sahil Rastogi
Published © GPL3+

Corona Wearable Distance Monitor

This Simple Wearable device changes its color and pitch of sound if any person comes close to you than 1m in times of COVID-19.

BeginnerFull instructions provided3 hours1,993

Things used in this project

Hardware components

Orange 360 mAh 1S 30C/60C Lithium polymer battery Pack (LiPo)
×1
TP4056 1A Li-ion lithium Battery Charging Module with Current Protection – Mini USB
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1
Buzzer
Buzzer
×1
NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
NeoPixel Ring: WS2812 5050 RGB LED
Adafruit NeoPixel Ring: WS2812 5050 RGB LED
×1
UTSOURCE Electronic Parts
UTSOURCE Electronic Parts
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

coronadistancemonitor_sHT0HbvXzq.png

Schematics

Connect the Components same as schematics

Code

Code

Arduino
Use Arduino IDE
#include<Adafruit_NeoPixel.h>

#define ledPin D3
#define buzzerPin D2
#define echoPin D5
#define trigPin D6
#define ledNo 16

Adafruit_NeoPixel ring = Adafruit_NeoPixel(ledNo,ledPin,NEO_RGB+NEO_KHZ800);

int minDistance = 50, maxDistance = 80;

void setup() 
{
  pinMode(buzzerPin, OUTPUT);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  ring.begin();
  for(int i = 0; i < ledNo; i++)
  {
    ring.setPixelColor(i,ring.Color(0,0,0));
  }
  ring.show();
}

void loop() 
{
  int distance = calcDistance();
  int ledsToGlow = map(distance, minDistance, maxDistance, ledNo, 1);
  if(ledsToGlow == 16)
  {
    digitalWrite(buzzerPin, HIGH);
  }
  else
  {
    digitalWrite(buzzerPin, LOW);
  }
  for(int i = 0; i < ledsToGlow; i++)
  {
    if(i < 6)
    {
      ring.setPixelColor(i,ring.Color(50,0,0));//g,r,b
    }
    else if(i >= 6 && i < 12)
    {
      ring.setPixelColor(i,ring.Color(50,50,0));//g,r,b
    }
    else if(i >= 12 && i < 16)
    {
      ring.setPixelColor(i,ring.Color(0,50,0));//g,r,b
    }
  }
  for(int i = ledsToGlow; i < ledNo; i++)
  {
    ring.setPixelColor(i,ring.Color(0,0,0));
  }
  ring.show();
  delay(150);
}

int calcDistance()
{
  long distance,duration;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration/29/2;
  if(distance >= maxDistance)
  {
    distance = maxDistance;
  }
  if(distance <= minDistance)
  {
    distance = minDistance;
  }
  return distance;
}

Credits

Random Stuff We Make!

Random Stuff We Make!

9 projects • 11 followers
We at RSWM! try to bring Fiction to Reality through projects which are Interactive, Creative & way too simpler in terms of making.
Sahil Rastogi

Sahil Rastogi

2 projects • 2 followers

Comments