1 / 11

Arduino Tutorial 2: Secret Door Knock Detector

Arduino Tutorial 2: Secret Door Knock Detector. Agenda. Sensor Review MAKE: calibrate sensor PWM Motors MAKE: calibrate motor Validation algorithm MAKE: Secret Knock Detector Links. Serial Monitor: Serial.begin (9600) to start communication

Télécharger la présentation

Arduino Tutorial 2: Secret Door Knock Detector

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Arduino Tutorial 2: Secret Door Knock Detector

  2. Agenda Sensor Review MAKE: calibrate sensor PWM Motors MAKE: calibrate motor Validation algorithm MAKE: Secret Knock Detector Links

  3. Serial Monitor: • Serial.begin(9600) to start communication • Serial.println(“msg”) to print to monitor Analog Review • Analog Arduino mapping: 0-5V  0 -1023 analogRead(pin) • Piezo: vibration sensor Generates voltage between its 2 leads Sensitive! Needs resistor in parallel

  4. MAKE: Calibrate Sensor • Connect sensor to analog pin with 1M resistor in parallel • Open skeleton_sensor_calibrate • Use Serial Monitor to report value from sensor, find out minimum value produced by a knock  THRESHOLD • Modify delay between readings so it won’t ignore two quick knocks or give you extra knocks  DEBOUNCE CHALLENGE: • Add LED to indicate knock

  5. Pulse Width Modulation • Duty cycle = percentage of time signal is positive in square wave • Min-Max voltage: 0 – 5v • Min-Max Arduino mapping: 0 – 255 • PWM pins have a ~ on Arduino 10% average 50% average 90% average

  6. DC Motors • They draw more current than USB/Arduino can supply (40mA per pin) so need another power supply: batteries / wall-wart • Current through in 1 direction turns them in 1 direction 6v PWM • More voltage = More speed, control? • Use electronically controlled switch (transistor) between motor and batteries • Use PWM pin to control switch Motor

  7. Servo Motors • Moves to desired position and stops, limited range of 180° in 2 directions • 3 wires: power = red ground = brown control = yellow • Control circuit + potentiometer + DC motor + position shaft with gears • Control signal uses PWM, pulse width = position

  8. MAKE: Calibrate Motor • Connect Servo motor to PWM pin, power and ground • Open skeleton_motor_calibrate • Find “opened” and “closed” positions by sweeping shaft • **Don’t disconnect sensor, will use later! Servo Library • #include <Servo.h> • Create object • Object.attach(pin) • Object.write(position) *in degrees

  9. MAKE: Secret Knock Detector • Secret knock is stored as array of time intervals • Validation logic: compare time intervals within allowed error • Start with skeleton_basic_door_knock, using serial monitor • When that works add servo movement instead of printing • Verify code with staff and try the BIG DOOR!

  10. Useful Links Original Instructables project http://www.instructables.com/id/Secret-Knock-Detecting-Door-Lock/ MAKE projects http://makezine.com/arduino/ http://makezine.com/category/electronics/arduino/?post_type=projects Jeremy Blum Tutorials (#5: motors and transistors) http://www.jeremyblum.com/category/arduino-tutorials/

  11. Questions? Comments? Suggestions? academics@ieee.concordia.ca ieee.concordia.ca

More Related