Presentation is loading. Please wait.

Presentation is loading. Please wait.

CTY SAR FCPS Shawn Lupoli, Elliot Tan

Similar presentations


Presentation on theme: "CTY SAR FCPS Shawn Lupoli, Elliot Tan"— Presentation transcript:

1 CTY SAR FCPS Shawn Lupoli, Elliot Tan
Arduino Knock Lab CTY SAR FCPS Shawn Lupoli, Elliot Tan

2 What are we working with?

3 How to detect a physical Knock?
A Piezo element can be used to detect vibration, which is produced by our knock. Piezo is an electronic device which generates a voltage when it is physically deformed by a vibration, sound wave or mechanical strain Can also put a voltage across a piezo  piezo will vibrate and create a tone If the sensors output is stronger than a certain threshold, the Arduino will be knocked

4 Arduino Knock Schematic

5 Goal When we “Knock” the piezo element The LED will flash
“Knock!” will be printed to the Serial Monitor

6 Programming “Knock”

7 Knock: Part 1 Initializing global variables Setup()
The LED will be connected to pin 13 The piezo is connected to analog pin 0 (A0) Threshold value = 1 A variable to store the sensor reading A variable to store the last LED status Setup() pinMode(pin, mode) configures the pin to behave either as an input or an output Serial.begin(9600) starts using the Serial Port

8 Knock: Part 2 Loop() Read the sensor using analogRead()
If the sensor reading is greater than the threshold turn on the light update the LED pin using digitalWrite() Send string back to the computer’s Serial Monitor Add in a delay to avoid overloading the serial port buffer

9 CODE

10 Building the Knock circuit

11 Supplies 1 Arduino Leonardo board 1 breadboard
3 short wires (two black, one red) 1 medium wire (red) 2 long wires (two black) 1 LED 1 resistor (1 MΩ) 1 piezo element * Notes: Wires are 22 or 24 AWG, solid Short wires = 5 cm Medium wires = 12 cm Long wires = 16 cm

12 Diagram of Knock Circuit

13 Running and reading output
Run the program as normal, but open the Serial monitoring window for the Analog port.

14 Questions?


Download ppt "CTY SAR FCPS Shawn Lupoli, Elliot Tan"

Similar presentations


Ads by Google