KrypticCoconut
Published © GPL3+

Steal-O-Alarm

A box from which no one can steal your stuff!

BeginnerFull instructions provided926
Steal-O-Alarm

Things used in this project

Hardware components

Resistor 100k ohm
Resistor 100k ohm
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×1
Male/Male Jumper Wires
×1
Resistor 330 ohm
Resistor 330 ohm
×3
Arduino UNO
Arduino UNO
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
In he actual application used a mini breadboard but for the schematic( showing the concept) i will use the big one.
×1
Buzzer
Buzzer
i used the passive buzzer.
×1
LDR, 5 Mohm
LDR, 5 Mohm
Any resistance will do since the normal light doesn't go above 2000 unless you are in the sun but try getting at least 1 m ohm
×1
RGB Diffused Common Anode
RGB Diffused Common Anode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless
i didnt use a drill to punch the holes in which the led and ldr are going to be sticking but it is easier with it.( i used a screwdriver put the tin on the ground and the smashed it on the place where the hole was to be made)

Story

Read more

Schematics

The schematic for knowing the connections (please note the led and LDR are not synchronised

The schematic for knowing the connections (please note the led and LDR are not synchronized or pointing towards each other, thus this wont work) so this is just for knowing the connections

tin

Im using a Pokemon tin but you may use any and stick some mirror or aluminium foil in the trajectory of the light bulb's light diagonally

RGB LED sticking in

i just kinda bent the pins and stuck it in.

LDR

Stick it in the trajectory of the light

Resistors

Was kinda lazy stuck in the resistors like this, all of them are 330 ohms resisitors, all of them are connected to RGB led (refer to schematic)

Mini breadboard

i used a mini breadboard with a buzzer and the ldr on it, the resistor you see being used with the LDR is a 100k ohm resistor refer to schematic

The overall look

Trajectory of light

like this, try to bounce the light on the mirror and foil, i used the tin because it had a metal which reflected light

final product

Code

The code

C/C++
It's the code, pretty simple , I've commented it, go ahead and read it.
#define LDRpin A0 // defining LDR pin

int LDRValue = 0;
int gpin = 3;// green pin in RGB LED
int rpin = 4;//red pin
int bpin = 5;//blue pin
const int buz = 11;
int toggle = 0;
boolean replay = true;

void setup() {

  pinMode(gpin, OUTPUT);
  pinMode(rpin, OUTPUT);
  pinMode(bpin, OUTPUT);

  Serial.begin(9600);
}

void loop() {
//========================== C H E C K U P==========================
  if (replay == true) { // will trigger at starting
    digitalWrite(bpin, HIGH); //initial checkup, this creates white which has most light and easy to measure unlike blue, red or green
    digitalWrite(gpin, HIGH);
    digitalWrite(rpin, HIGH);
    delay(1000);
  }
  //====================================================================
  LDRValue = analogRead(LDRpin);
  Serial.println(LDRValue);
  //=========================BEEP PHASE 2==============================
  if (toggle == 1) { // we made this because after first initiative the replay is false so it wont trigger checkup the color will be blue whoose light is a bit low so we will have to change the requirements (it will scan blue)
    if (LDRValue > 940) {// lowest brightness value of blue when an object is not placed and lght flows as the directed.
      digitalWrite(bpin, LOW);
      digitalWrite(gpin, LOW);
      digitalWrite(rpin, HIGH);
      tone(buz, 1000);
      delay(250);
      tone(buz, 2000);
      digitalWrite(rpin, LOW);
      digitalWrite(gpin, LOW);
      digitalWrite(bpin, HIGH);
      delay(250);
      replay = false;
    }
  }
  
  //===============================B E E P phase 1=========================
  if (LDRValue >  978) { //lowest brightness value of white when an object is not placed and lght flows as the directed.
    digitalWrite(bpin, LOW);
    digitalWrite(gpin, LOW);
    digitalWrite(rpin, HIGH);
    tone(buz, 1000);
    delay(250);
    tone(buz, 2000);
    digitalWrite(rpin, LOW);
    digitalWrite(gpin, LOW);
    digitalWrite(bpin, HIGH);
    delay(250);
    toggle = 1; // now goes to line 27
    Serial.println(toggle);
    replay = false; // wont trigger the initial checkup so it doesnt trgger the checkup to interupt our beep with a white color
    //=============RESETTING THE BEEP after light level adjusted===========
  }
  else if (LDRValue < 940) {// max value of blue when obstructed by a object
    toggle = 0;
    noTone(buz);
    replay = true;
  }
}
//===================================================================

Getting to know your led color brightness

C/C++
Just un-comment the color you wanna test because you can have different brightness and you may have to enter different one from mine, juts note down the points i have labelled in the code.
#define LDRpin A0 // defining LDR pin

int LDRValue = 0;
int gpin = 3;// green pin in RGB LED
int rpin = 4;//red pin
int bpin = 5;//blue pin


void setup() {

  pinMode(gpin, OUTPUT);
  pinMode(rpin, OUTPUT);
  pinMode(bpin, OUTPUT);

  Serial.begin(9600);
}

void loop() {
   // digitalWrite(bpin, HIGH);
  //  digitalWrite(gpin, HIGH);//uncomment the one you want to test
   // digitalWrite(rpin, HIGH);

  LDRValue = analogRead(LDRpin);
  Serial.println(LDRValue);
}

Credits

KrypticCoconut
1 project • 2 followers

Comments