Alex Merchen
Created October 27, 2019 © GPL3+

Glasses Finder

Create a place to store your glasses so you can find them easily at night.

BeginnerFull instructions provided4 hours85

Things used in this project

Hardware components

Resistor 1k ohm
Resistor 1k ohm
×1
LED (generic)
LED (generic)
×1
ATtiny85
Microchip ATtiny85
×1
Ultrasonic Sensor - HC-SR04
SparkFun Ultrasonic Sensor - HC-SR04
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering Iron Tip, 30° Sharp Bent
Soldering Iron Tip, 30° Sharp Bent

Story

Read more

Custom parts and enclosures

Shapeoko CAD File

13.5" by 15.5" by 0.25" thick MDF is needed in order to cut out the enclosure

Schematics

Schematic

Follow it to build the same circuit that I did

Code

ATTINY85 Code

Arduino
This sketch determines the distance and then if the distance is within 10 inches turn on the LED for 10 seconds
/*
This is for the hackster.io AARP contest

I am using the:
HC-SR04 Ping distance sensor
ATTINY85
LEDs
Resistors

All this sketch does is determine the distance and then if the distance is 
within 10 inches turn on the LED for 10 seconds
This will allow the user to wave their hand in the general vacinity and be 
able to find their glasses
*/

// Setup pins that we are going to use
#define trigPin 1
#define echoPin 2
#define led 3

// configure the pins
void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(led, OUTPUT);
}

void loop() {
  // setup a long type called duration and distance
  long duration, distance;
  // turn the trigger pin off for 5 microseconds
  digitalWrite(trigPin, LOW);
  delayMicroseconds(5); 
  // turn the trigger pin on for 10 microseconds
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10); 
  
  // Turn the trigger pin off again
  digitalWrite(trigPin, LOW);

  // wait for the echoPin to go high and determine that time
  duration = pulseIn(echoPin, HIGH);
  // convert the time into distance in inches
  distance = (duration/2) / 74;
  
  // if the distance is between 0 inches and 10 then turn on the LED for 10
  //seconds else turn it off
  if (distance < 10 && distance > 0) {
    digitalWrite(led,HIGH); 
    delay(10000);
}
  else {
    digitalWrite(led,LOW);
  }
  // delay 250ms and then start over
  delay(250);
}

Credits

Alex Merchen

Alex Merchen

19 projects • 26 followers
I'm an EE with a Masters in ECE. I like building things.

Comments