Thursday, December 16, 2010

Project Code

#include <Servo.h>
#define CLOSED 11
#define ALARM 13
int but = 0;
const int analogPin = 0;
const int ledCount = 8;
int ledPins[] = {
  2,3,4,5,6,7,8,9
  };  
Servo myservo;
int val = 0;
int sensorReading = 0;
#define soundalarm 10


//FUNCTIONS


void setup(){
  for (int thisLed = 0; thisLed < ledCount; thisLed++){
    pinMode(ledPins[thisLed], OUTPUT);
  }
  pinMode(CLOSED, INPUT);
  pinMode(ALARM, INPUT);
  pinMode(soundalarm, OUTPUT);
  myservo.attach(12);
  myservo.write(val);
}


void senRead(){
  int sensorReading = analogRead(analogPin);
  if (sensorReading < 550){
    senRead();
  }
  else{
    int ledLevel = map(sensorReading, 500, 1023, 0, ledCount);
    for (int thisLed = 0; thisLed < ledCount; thisLed++){
      if (thisLed < ledLevel){
        digitalWrite(ledPins[thisLed], HIGH);
      }
      else {
        digitalWrite(ledPins[thisLed], LOW);
      }
    }
  }
  if (sensorReading >= 975){
    senRead();
  }
  delay(1000);
}


void openDoor(){
  val = 1500;
  myservo.write(val);
  delay(1000);
}


void alarm(){
  int a = digitalRead(ALARM);
  if (a == HIGH){
    delay(1000);
    alarm2();
  }
  else{
    alarm();
  }
}

void alarm2(){
  int but = digitalRead(CLOSED);
  int a = digitalRead(ALARM);
  if (a == HIGH){
      digitalWrite(soundalarm, HIGH);
      delay(5000);
      digitalWrite(soundalarm, LOW);
      alarm2();
  }
  else{
    if (but == HIGH){
      val = 0;
      myservo.write(val);
      delay(1000);
      clearleds();
    }
    else{
      alarm2();
    }
  }
}
  
void clearleds(){
  for (int thisLed = 0; thisLed < ledCount; thisLed++){
    digitalWrite(ledPins[thisLed], LOW);
  }
}
 
 
 
  //MAIN LOOP


void loop(){
  senRead();
  openDoor();
  alarm();
}

Project 3 - Parts/Product

The whole electronic system

The LED indicators

The contact switch and buzzer

Basic contact switch

The MQ3 all wired up

The alarm

High torque servo

Finished cabinet


3/4 angle view of finished cabinet

Rear view of finished cabinet

Mood Board Pic

Inspirational/Helpful Sites

http://www.danielandrade.net/2010/03/07/building-an-breathalyzer-with-mq-3-and-arduino/

http://nootropicdesign.com/projectlab/2010/09/17/arduino-breathalyzer/

http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf

http://www.youtube.com/watch?v=sVbCqQAsUcs

Monday, November 22, 2010

Project 2 - Electronics Continued

Project 2 - Construction Video

Below is just a quick view around our whole housing for the shot dispenser to give you a look around the entire unit before being a finished piece.


Project 2 - Electronics

This is a short video of the basic servo operation where all we are doing is switching the servo position from 0 degrees to 180 degrees.

Project 2 - Construction

Below are a couple of pictures of our shot dispenser housing.  In this picture, we have the pieces cut, but not assembled or finished.
Building the shot dispenser cabinet

Shot dispenser cabinet

Monday, October 25, 2010

The MQ3 Sensor



Here is a quick image of the MQ-3 alcohol sensor, as well as its pin layout.  This alcohol sensor is compatible with the Arduino environment.

Project 2 - Outside Influences

http://vimeo.com/9975062
Here is a short video demonstration of where the inspiration for our project came from.

Thursday, October 21, 2010

Project 2

Today we ordered parts for our second project including a single shot dispenser, alcohol sensor, programmable LEDs, R/F transmitter, servos, touch screen monitor, and LCD display. Can't wait to get the parts in and see what we can put together!!

Monday, October 18, 2010