ledlights12456789GadhaGod
Created March 25, 2021

Protect eyes

put this product on tour desk or tablet so you can maintane space between.

Protect eyes

Things used in this project

Hardware components

LED (generic)
LED (generic)
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

space_by_ledlights123456789_RcN5Z2h0cT.png

Code

code :

C/C++
/*
'DISTANCE SENSOR:
Vcc goes to 5V on arduino
Gnd goes to ground pin on arduino.
Trigger goes to pin 8 on the arduino.
Echo goes to pin 9 on the arduino.

BUZZER:
Positive leg goes to pin 12 on the arduino.
Negative leg goes to GND on arduino.
*/
int trigPin = 8;    
int echoPin = 9;    

 
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  delay(100);
}
 
void loop() {
 
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  int duration = pulseIn(echoPin, HIGH);
  delay(50);
  
  if (duration <= 600){
    tone(12, 2000, 3000);
  }

  else{
    noTone(12);
    
  }
}

Credits

ledlights12456789
6 projects • 3 followers
GadhaGod
17 projects • 21 followers

Comments