Presentation is loading. Please wait.

Presentation is loading. Please wait.

Secret Door Knock Detector

Similar presentations


Presentation on theme: "Secret Door Knock Detector"— Presentation transcript:

1 Secret Door Knock Detector
1 Arduino Tutorial 2: Secret Door Knock Detector

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

3 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 Serial Monitor: Serial.begin(9600) to start communication Serial.println(“msg”) to print to monitor

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 Motor PWM 6v More voltage = More speed, control? Use electronically controlled switch (transistor) between motor and batteries Use PWM pin to control switch

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

8 MAKE: Calibrate Motor Servo Library
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 http://www.jeremyblum.com/category/arduino-tutorials/
Original Instructables project MAKE projects Jeremy Blum Tutorials (#5: motors and transistors)

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


Download ppt "Secret Door Knock Detector"

Similar presentations


Ads by Google