Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2022:agmocanu:electronicdoorgreeter [2022/05/27 23:01]
willi.maki [Conclusions]
pm:prj2022:agmocanu:electronicdoorgreeter [2022/05/27 23:39] (current)
willi.maki [Journal]
Line 7: Line 7:
 ===== General Description ===== ===== General Description =====
  
-The device uses 2 infrared sensors and an infrared emitter to detect movement. The sensors detect the infrared reflection reflecting off an object passing in front of them. The device is able to tell the direction of movement of the object depending on which infrared sensor gets triggered first. A short sound will be played by the use of an active ​buzzer only when detecting an entry.+The device uses 2 infrared sensors and an infrared emitter to detect movement. The sensors detect the infrared reflection reflecting off an object passing in front of them. The device is able to tell the direction of movement of the object depending on which infrared sensor gets triggered first. A short sound will be played by the use of a passive ​buzzer only when detecting an entry.
  
 ===== Block Scheme ===== ===== Block Scheme =====
Line 20: Line 20:
   * 2 IR sensors   * 2 IR sensors
   * IR source   * IR source
-  * Active ​Buzzer+  * Passive ​Buzzer
   * Button   * Button
  
Line 31: Line 31:
 Notes: Notes:
   * The software was programmed using Arduino IDE. No additional libraries were used.   * The software was programmed using Arduino IDE. No additional libraries were used.
-  * The IR sensors were designed for interpreting signals from remote controls and are thus sensitive mostly only to 3.8kHz ​IR signals.+  * The IR sensors were designed for interpreting signals from remote controls and are thus sensitive mostly only to 38kHz IR signals.
   * The tone() function was used to generate this frequency for the IR emitter.   * The tone() function was used to generate this frequency for the IR emitter.
  
 +<file c project.ino>​
 +const int buzzer=5; ​        //pin 5 is the buzzer output
 +const int ir_led=4; ​        //pin 4 is the ir_led output
 +const int push_button=3; ​   //pin 3 is the push_button input
 +volatile byte alarm = LOW;  //alarm state = on or off
 +
 +int noteArray[] = {740, 587};
 +
 +void setup(){
 +  Serial.begin(9600);​
 +  pinMode(buzzer,​OUTPUT); ​      //​configure pin 5 as OUTPUT
 +  pinMode(ir_led,​ OUTPUT); ​     //configure pin 4 as OUTPUT
 +  //​pinMode(push_button,​INPUT);​ //configure pin 3 as INPUT
 +  attachInterrupt(digitalPinToInterrupt(push_button),​ on_off, RISING);
 +}
 +
 +void loop(){
 +  if (alarm){
 +    int sensor0=analogRead(A0);​
 +    int sensor1=analogRead(A1);​
 +  ​
 +    Serial.println((String)"​sensor0 = " + sensor0);
 +    Serial.println((String)"​sensor1 = " + sensor1);
 +
 +    if(sensor0 < 1000){
 +      buzzer_sound(true);​
 +    } else if (sensor1 < 1000) {
 +      buzzer_sound(false);​
 +    } 
 +    ​
 +  }
 +}
 +
 +void on_off(){
 +  static unsigned long last_interrupt_time = 0;
 +  unsigned long interrupt_time = millis();
 +  // if interrupts come faster than 500ms, assume it's a bounce and ignore
 +  if (interrupt_time - last_interrupt_time > 500){
 +    alarm = !alarm;
 +    //​digitalWrite(ir_led,​ alarm);
 +    tone(ir_led,​ 38000);
 +  }
 +  last_interrupt_time = interrupt_time;​
 +}
 +
 +void buzzer_sound(bool in_out){
 +  noTone(ir_led);​
 +  delay(100);
 +  if(in_out){
 +    for(int i = 0; i < 2; i++){
 +        tone(buzzer,​ noteArray[i],​ 750);
 +        delay(500);
 +    }
 +  } else {
 +    for(int i = 1; i > -1; i--){
 +        tone(buzzer,​ noteArray[i],​ 750);
 +        delay(500);
 +    }
 +  }
 +  noTone(buzzer);​
 +  tone(ir_led,​ 38000);
 +  delay(2500);​
 +}
 +</​file>​
  
  
Line 41: Line 105:
  
 ===== Conclusions ===== ===== Conclusions =====
-I enjoyed putting into practice the things ​I've learned ​during ​the labs.+This project has taught me a lot about IR technology. For one, I've learned ​that working with IR was more complex than I anticipated. There'​s a lot of things that needs to be accounted for when choosing the proper IR component for your project, such as operating range, operating frequency, whether the IR sensor is sensitive to continuous rays or pulses, how the sensor handles noise etc
  
-If I were to work on another Arduino project in the future, I will definitely be doing more research into the needed components beforehand and try to minimize improvisation.+===== Journal ===== 
 +2022/05/27 - Completed Milestone 2
  
 ===== Resources ===== ===== Resources =====
pm/prj2022/agmocanu/electronicdoorgreeter.1653681679.txt.gz · Last modified: 2022/05/27 23:01 by willi.maki
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0