Things used in this project

Hardware components:
A000066 iso both
Arduino UNO & Genuino UNO
Or a compatible Arduino Uno Board
×1
Adafruit industries ada64 image 75px
Solderless Breadboard Half Size
×1
Mfr 25frf52 10k sml
Resistor 10k ohm
×3
11026 02
Jumper wires (generic)
×1
Adafruit industries ada161 image 75px
Photo resistor
×2
Laser Diode
×1
Omron b3f 1000 image 75px
Tactile Button Switch (6mm) Single
×1
Adafruit industries ada1536 image
Buzzer
×1
Software apps and online services:
Ide web
Arduino IDE

Schematics

Breadboard View
Breadboard View
Laser tripwire beep bb rnul0isroa
Schematic
Schematic view
Laser tripwire beep schem ygwdkxqt0e

Code

Laser TripwireArduino
// 5 pins trip wire

// Variables
int mode = 1;
int ambiant;
int trip = 1000; // The light value I get when using my laser
int minLight = 900;
int makeBeep = 1; //0 for no beep, 1 for beep!
int atAverage;
long millisCount;

// Output Pins
int laserPin = 2;
int ledPin = 13;
int buzzerPin = 3;
String  modeNames[3] = {"SETTINGS","ARMED","TRIP"};

// Input Pins
int modePin = 4; 
int tripPin = A0;
int ambiantPin = A1;


void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(laserPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(modePin, INPUT);
  Serial.begin(9600);
}


void loop() {

  // When the button is pushed
  if (digitalRead(modePin) == 1) {
    trip = analogRead(tripPin);
    mode=mode + 1;
    if (mode >= 2) {
      mode = 0;
    }
    beep(1);
    delay(300);
  }

  
  //does something when the mode changes
  switch (mode) {
    case 0: //calibration mode
      digitalWrite(laserPin,HIGH);
      
      ambiant = analogRead(ambiantPin);
      trip = analogRead(tripPin);
      atAverage = ambiant + ((trip - ambiant)/2);
      stats();
      
      if (trip  >= minLight) {
        digitalWrite(ledPin,HIGH);
      } else {
        digitalWrite(ledPin,LOW);
      }

    break;

    case 1: // Armed mode
      digitalWrite(laserPin,HIGH);
      digitalWrite(ledPin,LOW);
      ambiant = analogRead(ambiantPin);
      atAverage = ambiant + ((trip - ambiant)/2);
      if (analogRead(tripPin) < atAverage) {
        mode = 2;
      }
      if ((millis() - millisCount) >= 3000) {
        millisCount = millis();
        stats();
      }
    break;
    
    case 2: //Trip Mode
      if ((millis() - millisCount) >= 1000) {
        millisCount = millis();
        stats();
        beep(3);
        mode = 1;
      }
    break;
    }

    
  delay(1);                       // wait for a bit
}

//It Beeps
void beep(int qty) {
  int count;
  if (makeBeep == 1) {
    for (count = 1;count<=qty;count++) {
      digitalWrite(buzzerPin, HIGH);
      delay(50);
      digitalWrite(buzzerPin, LOW);
      delay(50);
    }
  }
}

//Writes stats to the Serial Port
void stats() {
  Serial.print("A:");
  Serial.print(ambiant);
  Serial.print(" T:");
  Serial.print(trip);
  Serial.print(" AT:");
  Serial.print(atAverage);
  Serial.print(" MODE:");
  Serial.print(modeNames[mode]);
  Serial.println("");
}

Credits

509f148d252c095177dfab08c0364567
Ian Cumming

I like stuff, from building rockets to elctronics.

Replications

Did you replicate this project? Share it!

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Voltmeter using Arduino
Easy
  • 39
  • 4

Protip

If you can't find voltmeter at home or at any other place, then this Hack is for you, Go ahead.

Voltmeter using Arduino

Team NextTechLab

Arduino morse code machine
Easy
  • 368
  • 7

Full instructions

A simple arduino Morse code machine with a button,led and a buzzer that takes your input and translates it into English while you are typing

USBphpTunnel
Easy
  • 88
  • 3

Protip

USBphpTunnel - Android app for MXQ TV box to control an Arduino board via USB from PHP.

Arduino 101 - Intel Curie Pattern Matching Dress
Easy
  • 1,464
  • 13

Full instructions

A dress with Curie's pattern matching engine on Arduino101 to control the embedded LEDs, which makes constellations show up on the dress.

Smart Home Sensor Node
Easy
  • 438
  • 5

Full instructions

Build a sensor node using Arduino/Genuino 101 which integrated with openHAB 2, which you can build a smart home control system in no time.

Chug Meter for St. Patrick's Day by Circuito.io
Easy
  • 1,706
  • 9

Full instructions

Let’s settle once and for all - who is the fastest chugger of ‘em all?

ProjectsCommunitiesContestsLiveJobsBetaFree StoreBlogAdd projectSign up / Login
Respect project
Feedback