SlideShare una empresa de Scribd logo
1 de 15
Level II Programming Piezo Sounder Alarm & Sensors In What??? Obviously easiest and fluent Arduino
Flash Back of previous session
What will you learn Today???  New methods of Arduino ,[object Object]
 analogRead ()
 analogWrite ()
 noTone ()Project ,[object Object]
	Project 2: Piezo Knock Sensor
	Project 3: Light Sensor,[object Object]
Project 1. Piezo Sounder Alarm Why use? By connecting a piezo sounder to a digital output pin, you can create a wailing 	alarm sound. What is required? 	Piezo Sounder (or piezo disc) 	2-Way Screw Terminal Piezo Sounder 2-Way Screw Terminal
How to connect? Now you know what has to be included in your code by watching at  pictorial representation above. But can you really code ??? Let’s try So you understood what is it that’s remaining…
// Project 1 - Piezo Sounder Alarm float sinVal; inttoneVal; void setup() { pinMode(8, OUTPUT); } void loop() { 	for (int x=0; x<180; x++) {  	 // convert degrees to radians then obtain sin value sinVal = (sin(x*(3.1412/180))); // generate a frequency from the sin value toneVal= 2000+(int(sinVal*1000)); 	tone(8, toneVal); 	delay(2); 	} }
The sinVal float variable holds the sin value that causes the tone to rise and fall The toneValvariable takes the value in sinVal and converts it to the frequency you require. You convert the value of x into radians : sinVal = (sin(x*(3.1412/180))); Then that value is converted into a frequency suitable for the alarm sound: toneVal = 2000+(int(sinVal*1000)); You take 2000 and add the sinVal multiplied by 1000. This supplies a good range of frequencies for the rising and falling tone of the sine wave. To make shrill sound and disturb someone who enters your room, I recommend you keep base value 1000 rather than 2000… :p
Project 2: Piezo Knock Sensor Why use? 	A piezo disc works when an electric current is passed over the ceramic material in the disc, causing it to change shape and hence make a sound (a click). The disc also works in reverse: when the disc is knocked or squeezed, the force on the material causes the generation of an electric current. You can read that current using the Arduino and you are going to do that now by making a Knock Sensor. What is required? 	Piezo Sounder (or piezo disc) 	2-Way Screw Terminal 	5mm LED (any color) 	1MΩ Resistor Piezo Sounder 2-Way Screw Terminal
//Project 2: Piezo knock sensor intledPin = 9;  int piezoPin = 5;  int threshold = 120; intsensorValue = 0;  float ledValue = 0; void setup() { pinMode(ledPin, OUTPUT);  digitalWrite(ledPin, HIGH); delay(150);  digitalWrite(ledPin, LOW); delay(150); digitalWrite(ledPin, HIGH); delay(150);  digitalWrite(ledPin, LOW); delay(150); } void loop() { sensorValue = analogRead(piezoPin);  	if (sensorValue >= threshold) {  ledValue= 255; 	} analogWrite(ledPin, int(ledValue) );  ledValue = ledValue - 0.05;  if (ledValue <= 0) { ledValue = 0;}  }

Más contenido relacionado

La actualidad más candente

Digital Tuner
Digital TunerDigital Tuner
Digital Tuner
plun
 
Dtmf Detection
Dtmf DetectionDtmf Detection
Dtmf Detection
biometria
 

La actualidad más candente (20)

All about ir arduino - cool
All about ir   arduino - coolAll about ir   arduino - cool
All about ir arduino - cool
 
DPLL PRESENTATION
DPLL PRESENTATIONDPLL PRESENTATION
DPLL PRESENTATION
 
Design of all digital phase locked loop (d pll) with fast acquisition time
Design of all digital phase locked loop (d pll) with fast acquisition timeDesign of all digital phase locked loop (d pll) with fast acquisition time
Design of all digital phase locked loop (d pll) with fast acquisition time
 
Voltage Controlled Oscillator Design - Short Course at NKFUST, 2013
Voltage Controlled Oscillator Design - Short Course at NKFUST, 2013Voltage Controlled Oscillator Design - Short Course at NKFUST, 2013
Voltage Controlled Oscillator Design - Short Course at NKFUST, 2013
 
RF Module Design - [Chapter 2] Noises
RF Module Design - [Chapter 2] NoisesRF Module Design - [Chapter 2] Noises
RF Module Design - [Chapter 2] Noises
 
Micro Assignment 1
Micro Assignment 1Micro Assignment 1
Micro Assignment 1
 
Digital Tuner
Digital TunerDigital Tuner
Digital Tuner
 
USB 2.0 Compliance Testing
USB 2.0 Compliance TestingUSB 2.0 Compliance Testing
USB 2.0 Compliance Testing
 
RF Module Design - [Chapter 8] Phase-Locked Loops
RF Module Design - [Chapter 8] Phase-Locked LoopsRF Module Design - [Chapter 8] Phase-Locked Loops
RF Module Design - [Chapter 8] Phase-Locked Loops
 
Circuit Network Analysis - [Chapter3] Fourier Analysis
Circuit Network Analysis - [Chapter3] Fourier AnalysisCircuit Network Analysis - [Chapter3] Fourier Analysis
Circuit Network Analysis - [Chapter3] Fourier Analysis
 
2012 1 arduino_rs232
2012 1 arduino_rs2322012 1 arduino_rs232
2012 1 arduino_rs232
 
R Study LT 02
R Study LT 02R Study LT 02
R Study LT 02
 
Dtmf Detection
Dtmf DetectionDtmf Detection
Dtmf Detection
 
Circuit Network Analysis - [Chapter2] Sinusoidal Steady-state Analysis
Circuit Network Analysis - [Chapter2] Sinusoidal Steady-state AnalysisCircuit Network Analysis - [Chapter2] Sinusoidal Steady-state Analysis
Circuit Network Analysis - [Chapter2] Sinusoidal Steady-state Analysis
 
Programming arduino makeymakey
Programming arduino makeymakeyProgramming arduino makeymakey
Programming arduino makeymakey
 
Hexapod ppt
Hexapod pptHexapod ppt
Hexapod ppt
 
Dsp U Lec09 Iir Filter Design
Dsp U   Lec09 Iir Filter DesignDsp U   Lec09 Iir Filter Design
Dsp U Lec09 Iir Filter Design
 
Cn1 connection details 36pins
Cn1 connection details 36pinsCn1 connection details 36pins
Cn1 connection details 36pins
 
Starting with Arduino
Starting with Arduino Starting with Arduino
Starting with Arduino
 
RF Module Design - [Chapter 6] Power Amplifier
RF Module Design - [Chapter 6]  Power AmplifierRF Module Design - [Chapter 6]  Power Amplifier
RF Module Design - [Chapter 6] Power Amplifier
 

Destacado (7)

All-Star Champions
All-Star ChampionsAll-Star Champions
All-Star Champions
 
Link building strategy
Link building strategyLink building strategy
Link building strategy
 
Orora group 2014 AGM presentation slides ASX release
Orora group 2014 AGM presentation slides ASX releaseOrora group 2014 AGM presentation slides ASX release
Orora group 2014 AGM presentation slides ASX release
 
Social Media for Crisis Management - Tips from the Coalface
Social Media for Crisis Management - Tips from the CoalfaceSocial Media for Crisis Management - Tips from the Coalface
Social Media for Crisis Management - Tips from the Coalface
 
Topik 1 pengenalan kepada pangkalan data
Topik 1   pengenalan kepada pangkalan dataTopik 1   pengenalan kepada pangkalan data
Topik 1 pengenalan kepada pangkalan data
 
Contoh karangan jenis fakta (1)
Contoh karangan jenis fakta (1)Contoh karangan jenis fakta (1)
Contoh karangan jenis fakta (1)
 
Pitot tube
Pitot tubePitot tube
Pitot tube
 

Similar a Session3

[Best]Chromatic Tuner Project Final Report
[Best]Chromatic Tuner Project Final Report[Best]Chromatic Tuner Project Final Report
[Best]Chromatic Tuner Project Final Report
Nicholas Ambrosio
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
HebaEng
 

Similar a Session3 (20)

Arduino projects &amp; tutorials
Arduino projects &amp; tutorialsArduino projects &amp; tutorials
Arduino projects &amp; tutorials
 
Electronz_Chapter_6.pptx
Electronz_Chapter_6.pptxElectronz_Chapter_6.pptx
Electronz_Chapter_6.pptx
 
Arduino
ArduinoArduino
Arduino
 
Embedded system course projects - Arduino Course
Embedded system course projects - Arduino CourseEmbedded system course projects - Arduino Course
Embedded system course projects - Arduino Course
 
Arduino Workshop
Arduino WorkshopArduino Workshop
Arduino Workshop
 
Physical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digitalPhysical prototyping lab2-analog_digital
Physical prototyping lab2-analog_digital
 
Arduino
ArduinoArduino
Arduino
 
[Best]Chromatic Tuner Project Final Report
[Best]Chromatic Tuner Project Final Report[Best]Chromatic Tuner Project Final Report
[Best]Chromatic Tuner Project Final Report
 
Mom presentation_monday_arduino in the physics lab
Mom presentation_monday_arduino in the physics labMom presentation_monday_arduino in the physics lab
Mom presentation_monday_arduino in the physics lab
 
Arduino Workshop (3).pptx
Arduino Workshop (3).pptxArduino Workshop (3).pptx
Arduino Workshop (3).pptx
 
Smart Safety Door based on Arduino Uno R3
Smart Safety Door based on Arduino Uno R3Smart Safety Door based on Arduino Uno R3
Smart Safety Door based on Arduino Uno R3
 
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors  B...Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors  B...
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
 
Porte à puce - Smart Safety Door based on Arduino UNO R3
Porte à puce - Smart Safety Door based on Arduino UNO R3Porte à puce - Smart Safety Door based on Arduino UNO R3
Porte à puce - Smart Safety Door based on Arduino UNO R3
 
Synchronous Time / Frequency Domain Measurements Using a Digital Oscilloscope...
Synchronous Time / Frequency Domain Measurements Using a Digital Oscilloscope...Synchronous Time / Frequency Domain Measurements Using a Digital Oscilloscope...
Synchronous Time / Frequency Domain Measurements Using a Digital Oscilloscope...
 
Arduino based applications part 1
Arduino based applications part 1Arduino based applications part 1
Arduino based applications part 1
 
Smart Blind stick by using arduino uno and sensor
 Smart Blind stick  by using arduino  uno  and sensor Smart Blind stick  by using arduino  uno  and sensor
Smart Blind stick by using arduino uno and sensor
 
Arduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz RadiosArduino Meetup with Sonar and 433Mhz Radios
Arduino Meetup with Sonar and 433Mhz Radios
 
Arduino frequency counter
Arduino frequency counterArduino frequency counter
Arduino frequency counter
 
publish manual
publish manualpublish manual
publish manual
 
INT4073 L07(Sensors and AcutTORS).pdf
INT4073 L07(Sensors and AcutTORS).pdfINT4073 L07(Sensors and AcutTORS).pdf
INT4073 L07(Sensors and AcutTORS).pdf
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 

Session3

  • 1. Level II Programming Piezo Sounder Alarm & Sensors In What??? Obviously easiest and fluent Arduino
  • 2. Flash Back of previous session
  • 3.
  • 4.
  • 7.
  • 8. Project 2: Piezo Knock Sensor
  • 9.
  • 10. Project 1. Piezo Sounder Alarm Why use? By connecting a piezo sounder to a digital output pin, you can create a wailing alarm sound. What is required? Piezo Sounder (or piezo disc) 2-Way Screw Terminal Piezo Sounder 2-Way Screw Terminal
  • 11. How to connect? Now you know what has to be included in your code by watching at pictorial representation above. But can you really code ??? Let’s try So you understood what is it that’s remaining…
  • 12. // Project 1 - Piezo Sounder Alarm float sinVal; inttoneVal; void setup() { pinMode(8, OUTPUT); } void loop() { for (int x=0; x<180; x++) { // convert degrees to radians then obtain sin value sinVal = (sin(x*(3.1412/180))); // generate a frequency from the sin value toneVal= 2000+(int(sinVal*1000)); tone(8, toneVal); delay(2); } }
  • 13. The sinVal float variable holds the sin value that causes the tone to rise and fall The toneValvariable takes the value in sinVal and converts it to the frequency you require. You convert the value of x into radians : sinVal = (sin(x*(3.1412/180))); Then that value is converted into a frequency suitable for the alarm sound: toneVal = 2000+(int(sinVal*1000)); You take 2000 and add the sinVal multiplied by 1000. This supplies a good range of frequencies for the rising and falling tone of the sine wave. To make shrill sound and disturb someone who enters your room, I recommend you keep base value 1000 rather than 2000… :p
  • 14. Project 2: Piezo Knock Sensor Why use? A piezo disc works when an electric current is passed over the ceramic material in the disc, causing it to change shape and hence make a sound (a click). The disc also works in reverse: when the disc is knocked or squeezed, the force on the material causes the generation of an electric current. You can read that current using the Arduino and you are going to do that now by making a Knock Sensor. What is required? Piezo Sounder (or piezo disc) 2-Way Screw Terminal 5mm LED (any color) 1MΩ Resistor Piezo Sounder 2-Way Screw Terminal
  • 15. //Project 2: Piezo knock sensor intledPin = 9; int piezoPin = 5; int threshold = 120; intsensorValue = 0; float ledValue = 0; void setup() { pinMode(ledPin, OUTPUT); digitalWrite(ledPin, HIGH); delay(150); digitalWrite(ledPin, LOW); delay(150); digitalWrite(ledPin, HIGH); delay(150); digitalWrite(ledPin, LOW); delay(150); } void loop() { sensorValue = analogRead(piezoPin); if (sensorValue >= threshold) { ledValue= 255; } analogWrite(ledPin, int(ledValue) ); ledValue = ledValue - 0.05; if (ledValue <= 0) { ledValue = 0;} }
  • 16. Project 3: Light Sensor Why use? The more light, the lower the resistance. By reading the value from the sensor, you can detect if it is light, dark, or anywhere between. In this project, you use an LDR to detect light and a piezo sounder to give audible feedback of the amount of light detected. This setup could be used as an alarm that indicates when a door has been opened, for example. Alternatively, you could use it to create a musical instrument similar to a Theremin. What is required? Piezo Sounder (or piezo disc) 2-Way Screw Terminal Light Dependent Resistor 10kΩ Resistor Piezo Sounder 2-Way Screw Terminal
  • 17. How is it connected…
  • 18. Code… // Project 14 - Light Sensor int piezoPin = 8; int ldrPin = 0; intldrValue = 0; void setup() { // nothing to do here } void loop() { ldrValue = analogRead(ldrPin); tone(piezoPin,1000); delay(25); noTone(piezoPin); delay(ldrValue); }
  • 19. Mechanism: LDR Working Vout = Vin * R2/(R2+R1) Table 4-1. Vout values for a LDR with 5v as Vin R1 R2 (LDR) Vout Brightness 10kΩ 100kΩ 4.54v Darkest 10kΩ 73kΩ 4.39v 25% 10kΩ 45kΩ 4.09v 50% 10kΩ 28kΩ 3.68v 75% 10kΩ 10kΩ 2.5v Brightest As you can see, as the brightness increases, the voltage at Vout decreases. As a result, the value you read at the sensor gets less and the delay after the beep gets shorter, causing the beeps to occur more frequently. If you were to switch the resistor and LDR, the voltage would increase as more light fell onto the LDR. Either way will work; it just depends how you want your sensor to be read.