Rohan Barnwal
Published © GPL3+

Forget-Me-Glass: The Smart Glass Holder

The Smart Glass Holder That Saves You from Your Mom (and Your Laziness

BeginnerFull instructions provided1 hour37
Forget-Me-Glass: The Smart Glass Holder

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×1
IR Sensor
×1
Buzzer
Buzzer
×1
UNO R4 WiFi
Arduino UNO R4 WiFi
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Connections

Code

Code

Arduino
#include "ArduinoGraphics.h"
#include "Arduino_LED_Matrix.h"

ArduinoLEDMatrix matrix;

const int irPin = 2;       // IR sensor input pin
const int buzzerPin = 3;   // Buzzer output pin

void setup() {
  Serial.begin(115200);
  matrix.begin();
  pinMode(irPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  digitalWrite(buzzerPin, LOW);
}

void loop() {
  if (digitalRead(irPin) == HIGH) {
    // No glass - show happy face
    matrix.loadFrame(LEDMATRIX_EMOJI_HAPPY);
    digitalWrite(buzzerPin, LOW);
    delay(100);
  }

  if (digitalRead(irPin) == LOW) {
    // Glass placed - start countdown
    for (int count = 60; count >= 0; count--) {
      if (digitalRead(irPin) == HIGH) break;

      matrix.beginDraw();
      matrix.stroke(0xFFFFFFFF);
      matrix.clear();
      matrix.textFont(Font_5x7);
      matrix.beginText(0, 1, 0xFFFFFF);
      matrix.println(count);
      matrix.endText();
      matrix.endDraw();

      delay(1000);
    }

    // Glass is still there - now it screams
    while (digitalRead(irPin) == LOW) {
      matrix.loadFrame(LEDMATRIX_EMOJI_BASIC);  // Judgy stare
      digitalWrite(buzzerPin, HIGH);            // Scream time
      delay(100);
    }

    digitalWrite(buzzerPin, LOW); // Silence once you're responsible again
  }
}

Credits

Rohan Barnwal
37 projects • 35 followers
Rohan Barnwal - maker, hacker, tech enthusiast. I explore new tech & find innovative solutions. See my projects on hackster.io!

Comments