Watching Video Eyes Protecter

by nathan940404 in Circuits > Arduino

117 Views, 0 Favorites, 0 Comments

Watching Video Eyes Protecter

image_6487327 (6).JPG

People now often hurt their eyes because their distance between their eyes and the screen is too close. So I made this device to make sure people can keep their distance while they using 3C.

Downloads

Step1: ​ Connect the Wires As Shown in This Picture.

F1T3TQ2H994BXMB.jpg

Step2: Add Outward to Made This Device Better.

image_6487327 (7).JPG

Step3: Write a [too Close] and a [OK] to Let People Know the Distinguish Between Too Close and Appropriate.

image_6487327 (5).JPG

Step 4: Video

Code

/*

HC-SR04 Ping distance sensor] VCC to arduino 5v GND to arduino GND Echo to Arduino pin 13 Trig to Arduino pin 12 Red POS to Arduino pin 11 Green POS to Arduino pin 10 560 ohm resistor to both LED NEG and GRD power rail More info at: http://goo.gl/kJ8Gl Original code improvements to the Ping sketch sourced from Trollmaker.com Some code and wiring inspired by http://en.wikiversity.org/wiki/User:Dstaub/robotcar */

#define trigPin 13 #define echoPin 12 #define led 11 #define led2 10

void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(led, OUTPUT); pinMode(led2, OUTPUT); }

void loop() { long duration, distance; digitalWrite(trigPin, LOW); // Added this line delayMicroseconds(2); // Added this line digitalWrite(trigPin, HIGH); // delayMicroseconds(1000); - Removed this line delayMicroseconds(10); // Added this line digitalWrite(trigPin, LOW); duration = pulseIn(echoPin, HIGH); distance = (duration/2) / 29.1; if (distance < 4) { // This is where the LED On/Off happens digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off digitalWrite(led2,LOW); } else { digitalWrite(led,LOW); digitalWrite(led2,HIGH); } if (distance >= 200 || distance <= 0){ Serial.println("Out of range"); } else { Serial.print(distance); Serial.println(" cm"); } delay(500); }