'Too Close to the Screen' Alarm
by TechMartian in Circuits > Assistive Tech
2207 Views, 13 Favorites, 0 Comments
'Too Close to the Screen' Alarm
![IMG_2372.jpg](/proxy/?url=https://content.instructables.com/FGT/VIM3/J6QQX380/FGTVIM3J6QQX380.jpg&filename=IMG_2372.jpg)
This is an alarm that alerts the user if they are staring at a computer screen too close and too long. It uses an ultrasonic depth sensor mounted just above the laptop's webcam to check if there's a person in front of it and how long they have been 'glued' to it. If it's too close or too long, it will sound an alarm continuously and annoyingly until you move away from it!
As a software develop I spend the majority of my day staring at the computer screen. When I get home, due to my slight internet addiction problem, the first thing I do is crack open my laptop. In total I probably spend 16 hours in front of a computer screen, so I wanted an alarm that tells me if I get too close to it to prevent further damage to my already poor eyesight.
Connections
![IMG_20170827_172228.jpg](/proxy/?url=https://content.instructables.com/F7G/4N4C/J6QQX390/F7G4N4CJ6QQX390.jpg&filename=IMG_20170827_172228.jpg)
![IMG_20170827_172239.jpg](/proxy/?url=https://content.instructables.com/FNX/AZJK/J6QQX3C9/FNXAZJKJ6QQX3C9.jpg&filename=IMG_20170827_172239.jpg)
![IMG_20170827_172246.jpg](/proxy/?url=https://content.instructables.com/FV4/H3IF/J6QQX3EA/FV4H3IFJ6QQX3EA.jpg&filename=IMG_20170827_172246.jpg)
Follow the following table for the connections that are made between the peripherals (Ultrasonic and Buzzer) and the Arduino board.
I/O | Pin # | Arduino Pin # |
---|---|---|
Buzzer* | 1 | 6 |
Buzzer* | 2 | GND** |
Ultrasonic | Trig | 9 |
Ultrasonic | Echo | 10 |
Ultrasonic | VCC | 3.3V |
Ultrasonic | GND | GND** |
* In any order - no order constraint.
** There are at least 3 GND pins on the Arduino board
Code
![Screen Shot 2017-08-28 at 10.07.44 AM.png](/proxy/?url=https://content.instructables.com/FZX/74JL/J6QQZ8FR/FZX74JLJ6QQZ8FR.png&filename=Screen Shot 2017-08-28 at 10.07.44 AM.png)
// defines pins numbers
const int trigPin = 9; const int echoPin = 10; const int buzzer = 6;
// defines variables long duration; int distance; int safetyDistance;
void setup() { pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output pinMode(echoPin, INPUT); // Sets the echoPin as an Input pinMode(buzzer, OUTPUT);
safetyDistance = 100; tone(buzzer, 2500); delay(500); tone (buzzer, 2500);
Serial.begin(9600); // Starts the serial communication }
void loop() {
// Clears the trigPin digitalWrite(trigPin, LOW); delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds digitalWrite(trigPin, HIGH); delayMicroseconds(10); digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH);
// Calculating the distance distance= duration*0.034/2;
if (distance <= safetyDistance){ tone(buzzer, 2500); delay(500); tone (buzzer, 2500); } else{ noTone (buzzer); }
// Prints the distance on the Serial Monitor Serial.print("Distance: "); Serial.println(dist); }
Mount
![IMG_2369.jpg](/proxy/?url=https://content.instructables.com/FFF/9W5A/J6QQX322/FFF9W5AJ6QQX322.jpg&filename=IMG_2369.jpg)
![IMG_2370.JPG](/proxy/?url=https://content.instructables.com/F45/VZD7/J6QQX33S/F45VZD7J6QQX33S.jpg&filename=IMG_2370.JPG)
Tape the Arduino to the back of your Laptop.
Tape the Ultrasonic sensor just over your webcam. It would naturally balance there due to the overhang but it's safer to tape the wires securely so it doesn't move.
Lastly, tape the buzzer onto the corner of the laptop.
Done!
![IMG_2371.jpg](/proxy/?url=https://content.instructables.com/F47/5I7O/J6QQX35U/F475I7OJ6QQX35U.jpg&filename=IMG_2371.jpg)
Hang it on your laptop or computer monitor and start using your computer healthier!
Live long and Prosper!