SlideShare a Scribd company logo
1 of 6
INGREDIENTS
15
220 OHM RESISTOR
OPTOCOUPLER
GET CONTROL OF OTHER COMPONENTS AROUND YOU.
USING SOME ADDITIONAL CIRCUITRY, YOU CAN “PRESS”
BUTTONS WITH YOUR ARDUINO
Warning: You’re no longer a beginner if you’re doing this project. You’ll be opening
up an electronic device and modifying it. You’ll void your device’s warranty, and if
you’re not careful, you might damage the device. Make sure you’re familiar with
all the electronics concepts in the earlier projects before you attempt this one. We
recommend you use inexpensive items you don’t mind damaging for your first few
projects, until you develop experience and confidence.
While the Arduino can control a lot of things, sometimes it’s easier to use tools
that are created for specific purposes. Perhaps you want to control a television
or a music player, or drive a remote control car. Most electronic devices have a
control panel with buttons, and many of those buttons can be hacked so that
you can “press” them with an Arduino. Controlling recorded sound is a good
example. If you wanted to record and play back recorded sound, it would take
a lot of effort to get the Arduino to do that. It’s much easier to get a small
device that records and plays back sound, and replace its buttons with outputs
controlled by your Arduino.
Optocouplers are integrated circuits that allow you to control one circuit from
a different one without any electrical connection between the two. Inside an
optocoupler is an LED and a light detector. When the LED in the optocoupler
is turned on by your Arduino, the light detector closes a switch internally. The
switch is connected to two of the output pins (4 and 5) of the optocoupler.
When the internal switch is closed, the two output pins are connected. When the
switch is open, they’re not connected. This way, it’s possible to close switches on
other devices without connecting them to your Arduino.
Discover: optocoupler, connecting with other components
Time: 45 MINUTES Builds on projects: 1,2,9
Level:
HACKING
BUTTONS
157
BUILD THE
CIRCUIT
Fig.1
Fig.2
In this example, the diagrams are for controlling a digital recording module that allows you to
record and playback 20 seconds of sound, but the basic premise holds for any device that has
a switch you can access. While it’s possible to use this example without soldering any wires, it
certainly makes things easier. For more information on soldering, see p. 134.
158 Project 15
Hacking Buttons
Connect ground to your breadboard through the Arduino.
Place the optocoupler on your breadboard so that it straddles
the center of the board (see circuit diagram).
Connect pin 1on the optocoupler to Arduino pin 2 in series with
a 220-ohm resistor (remember, you’re powering an LED inside,
you don’t want to burn it out). Connect pin 2 of the optocou-
pler to ground.
On the main board of the sound module there are a number of
electrical components, including a playback button.
To control the switch, you’re going to have to remove the but-
ton. Flip the circuit board over and find the tabs that hold the
button in place. Gently bend the tabs back and remove the but-
ton from the board.
Under the button are two small metal plates. This pattern is
typical of many electronic devices with pushbuttons. The two
“forks” of this pattern are the two sides of the switch. A small
metal disc inside the pushbutton connects these two forks
when you press the button.
When the forks are connected, the switch is closed on the circuit
board. You will be closing the switch with the optocoupler.
This method, closing a switch with an optocoupler, works only if
one of the two sides of the pushbutton’s switch is connected to
ground on your device. If you’re not sure, take a multimeter and
measure the voltage between one of the forks and the ground
on your device. You need to do this with the device turned on, so
be careful not to touch anywhere else on the board.
Once you know which fork is ground, disconnect the power to
your device.
Next, connect one wire to each of the small metal plates. If you
are soldering these wires, be careful to not join the two sides
of the switch together. If you are not soldering and using tape,
make sure your connection is secure, or the switch won’t close.
Make sure neither wire connects to the other fork, or your switch
will be closed all the time.
Attach the two wires to pins 4 and 5 of the optocoupler. Connect
the side of the switch that is grounded to pin 4 of the optocou-
pler. Connect the other fork to pin 5 of the optocoupler.
❶
❷
❸
❹
❺
❻
❼
❽
159
Most of the fun with this project is in the circuit and the
optocoupler. The code is similar to the first project you made
with the Arduino. You’re going to play the sound once every 20
seconds by turning pin 2 HIGH.
Create a constant for the optocoupler control pin.
In setup(),set the optocoupler pin into an output.
The loop() turns optoPin HIGH for a few milliseconds, long
enough for the optocoupler to close the switch on the device.
Then the optoPin becomes LOW.
Wait for 21 seconds for the whole message to play back before
starting the loop() again.
THE CODE
Attach the battery to the sound recorder. Press and hold the
record button on the device. While you’re holding the button,
you can record audio into the microphone. Use your voice, the
cat, or the pots and pans in the kitchen to make some noise
(but be careful with the cat).
Once you’ve satisfactorily recorded a sound, power your Ar-
duino with the USB cable. Your recording should start to play.
If you recorded for the full 20 seconds, the sound should start
again just a few moments after it ends.
USE IT
Try experimenting with different sounds and durations of toggling the playback
with the delay() in your program.
If you trigger the switch while a sound is playing, it will stop. How can you take
advantage of this to create unique sequences of sounds?
Name a constant
Configure the pin direction
Pull the pin high and low
Wait for a little while
160 Project 15
Hacking Buttons
1 const int optoPin = 2;
2 void setup(){
3pinMode(optoPin, OUTPUT); 4
}
5 void Loop(){
6digitaLWrite(optoPin, HIGH); 7
deLay(15);
8 digitaLWrite(optoPin, LOW);
9 deLay(21000);
10 }
Integrated circuits are in virtually every electronic device. The large 28 pin chip on
your Arduino is an IC that houses the brains of the board. There are other ICs that
support this one with communication and power. The optocoupler and main chip on
the Arduino are Dual In-line Package (DIP) chips. These DIP chips are the kind that
most hobbyists use because they easily fit in a breadboard and don’t have to be per-
manently soldered to be used.
The project example only played sound back at a regular interval. How could you
incorporate the inputs from earlier projects to trigger these sounds? What other
battery powered things do you have around the house that need an Arduino to con-
trol them? This technique of controlling an electronic device with an optocoupler by
connecting to the two sides of a switch can be used in many other devices. What
other devices do you want to control?
Optocouplers can control devices that are on a different
circuit.Thetwocircuitsareelectricallyseparatedfromeach
otherinsidethecomponent.
161

More Related Content

Similar to Electronz_Chapter_15.pptx

KEYBOARD INSTRUMENT
KEYBOARD INSTRUMENTKEYBOARD INSTRUMENT
KEYBOARD INSTRUMENTRashmi1426
 
Arduino comic v0004
Arduino comic v0004Arduino comic v0004
Arduino comic v0004DO!MAKERS
 
Arduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchArduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchRatzman III
 
Arduino PAPER ABOUT INTRODUCTION
Arduino PAPER ABOUT INTRODUCTION  Arduino PAPER ABOUT INTRODUCTION
Arduino PAPER ABOUT INTRODUCTION NAGASAI547
 
Digital home automation with arduino bluetooth
Digital home automation with arduino bluetoothDigital home automation with arduino bluetooth
Digital home automation with arduino bluetoothShishupal03012015
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slidesmkarlin14
 
Arduino slides
Arduino slidesArduino slides
Arduino slidessdcharle
 
Arduino based home automation using tv remote
Arduino based home automation using tv remoteArduino based home automation using tv remote
Arduino based home automation using tv remoteMahbub Alam Himel
 
Report 171115175724
Report 171115175724Report 171115175724
Report 171115175724PAVINRAJ5
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino AMIT SANPUI
 
Chapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxChapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxkhgh7
 
Electronz_Chapter_2.pptx
Electronz_Chapter_2.pptxElectronz_Chapter_2.pptx
Electronz_Chapter_2.pptxMokete5
 
Arduino bt mobile robot r2.0
Arduino bt mobile robot r2.0Arduino bt mobile robot r2.0
Arduino bt mobile robot r2.0Fajar Baskoro
 

Similar to Electronz_Chapter_15.pptx (20)

publish manual
publish manualpublish manual
publish manual
 
KEYBOARD INSTRUMENT
KEYBOARD INSTRUMENTKEYBOARD INSTRUMENT
KEYBOARD INSTRUMENT
 
Arduino Comic-Jody Culkin-2011
Arduino Comic-Jody Culkin-2011Arduino Comic-Jody Culkin-2011
Arduino Comic-Jody Culkin-2011
 
Arduino comic v0004
Arduino comic v0004Arduino comic v0004
Arduino comic v0004
 
Arduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchArduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick Switch
 
Arduino PAPER ABOUT INTRODUCTION
Arduino PAPER ABOUT INTRODUCTION  Arduino PAPER ABOUT INTRODUCTION
Arduino PAPER ABOUT INTRODUCTION
 
Digital home automation with arduino bluetooth
Digital home automation with arduino bluetoothDigital home automation with arduino bluetooth
Digital home automation with arduino bluetooth
 
Arduino guide
Arduino guideArduino guide
Arduino guide
 
Arduino Workshop Slides
Arduino Workshop SlidesArduino Workshop Slides
Arduino Workshop Slides
 
Arduino slides
Arduino slidesArduino slides
Arduino slides
 
Lab2ppt
Lab2pptLab2ppt
Lab2ppt
 
Arduino based home automation using tv remote
Arduino based home automation using tv remoteArduino based home automation using tv remote
Arduino based home automation using tv remote
 
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
 
Report 171115175724
Report 171115175724Report 171115175724
Report 171115175724
 
Project report on home automation using Arduino
Project report on home automation using Arduino Project report on home automation using Arduino
Project report on home automation using Arduino
 
Chapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptxChapter 5 Arduino Microcontroller Systems .pptx
Chapter 5 Arduino Microcontroller Systems .pptx
 
Arduino Family
Arduino FamilyArduino Family
Arduino Family
 
arduino uno
arduino unoarduino uno
arduino uno
 
Electronz_Chapter_2.pptx
Electronz_Chapter_2.pptxElectronz_Chapter_2.pptx
Electronz_Chapter_2.pptx
 
Arduino bt mobile robot r2.0
Arduino bt mobile robot r2.0Arduino bt mobile robot r2.0
Arduino bt mobile robot r2.0
 

More from Mokete5

Electronz_Chapter_13.pptx
Electronz_Chapter_13.pptxElectronz_Chapter_13.pptx
Electronz_Chapter_13.pptxMokete5
 
Electronz_Chapter_14.pptx
Electronz_Chapter_14.pptxElectronz_Chapter_14.pptx
Electronz_Chapter_14.pptxMokete5
 
Electronz_Chapter_12.pptx
Electronz_Chapter_12.pptxElectronz_Chapter_12.pptx
Electronz_Chapter_12.pptxMokete5
 
Electronz_Chapter_8.pptx
Electronz_Chapter_8.pptxElectronz_Chapter_8.pptx
Electronz_Chapter_8.pptxMokete5
 
Electronz_Chapter_10.pptx
Electronz_Chapter_10.pptxElectronz_Chapter_10.pptx
Electronz_Chapter_10.pptxMokete5
 
Electronz_Chapter_7.pptx
Electronz_Chapter_7.pptxElectronz_Chapter_7.pptx
Electronz_Chapter_7.pptxMokete5
 
Electronz_Chapter_11.pptx
Electronz_Chapter_11.pptxElectronz_Chapter_11.pptx
Electronz_Chapter_11.pptxMokete5
 
Electronz_Chapter_6.pptx
Electronz_Chapter_6.pptxElectronz_Chapter_6.pptx
Electronz_Chapter_6.pptxMokete5
 
Electronz_Chapter_4.pptx
Electronz_Chapter_4.pptxElectronz_Chapter_4.pptx
Electronz_Chapter_4.pptxMokete5
 
Electronz_Chapter_3.pptx
Electronz_Chapter_3.pptxElectronz_Chapter_3.pptx
Electronz_Chapter_3.pptxMokete5
 
Elecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptxElecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptxMokete5
 
Electronz_Introduction.pptx
Electronz_Introduction.pptxElectronz_Introduction.pptx
Electronz_Introduction.pptxMokete5
 

More from Mokete5 (12)

Electronz_Chapter_13.pptx
Electronz_Chapter_13.pptxElectronz_Chapter_13.pptx
Electronz_Chapter_13.pptx
 
Electronz_Chapter_14.pptx
Electronz_Chapter_14.pptxElectronz_Chapter_14.pptx
Electronz_Chapter_14.pptx
 
Electronz_Chapter_12.pptx
Electronz_Chapter_12.pptxElectronz_Chapter_12.pptx
Electronz_Chapter_12.pptx
 
Electronz_Chapter_8.pptx
Electronz_Chapter_8.pptxElectronz_Chapter_8.pptx
Electronz_Chapter_8.pptx
 
Electronz_Chapter_10.pptx
Electronz_Chapter_10.pptxElectronz_Chapter_10.pptx
Electronz_Chapter_10.pptx
 
Electronz_Chapter_7.pptx
Electronz_Chapter_7.pptxElectronz_Chapter_7.pptx
Electronz_Chapter_7.pptx
 
Electronz_Chapter_11.pptx
Electronz_Chapter_11.pptxElectronz_Chapter_11.pptx
Electronz_Chapter_11.pptx
 
Electronz_Chapter_6.pptx
Electronz_Chapter_6.pptxElectronz_Chapter_6.pptx
Electronz_Chapter_6.pptx
 
Electronz_Chapter_4.pptx
Electronz_Chapter_4.pptxElectronz_Chapter_4.pptx
Electronz_Chapter_4.pptx
 
Electronz_Chapter_3.pptx
Electronz_Chapter_3.pptxElectronz_Chapter_3.pptx
Electronz_Chapter_3.pptx
 
Elecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptxElecronz_Chapter_1.pptx
Elecronz_Chapter_1.pptx
 
Electronz_Introduction.pptx
Electronz_Introduction.pptxElectronz_Introduction.pptx
Electronz_Introduction.pptx
 

Recently uploaded

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 

Recently uploaded (20)

Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 

Electronz_Chapter_15.pptx

  • 2. GET CONTROL OF OTHER COMPONENTS AROUND YOU. USING SOME ADDITIONAL CIRCUITRY, YOU CAN “PRESS” BUTTONS WITH YOUR ARDUINO Warning: You’re no longer a beginner if you’re doing this project. You’ll be opening up an electronic device and modifying it. You’ll void your device’s warranty, and if you’re not careful, you might damage the device. Make sure you’re familiar with all the electronics concepts in the earlier projects before you attempt this one. We recommend you use inexpensive items you don’t mind damaging for your first few projects, until you develop experience and confidence. While the Arduino can control a lot of things, sometimes it’s easier to use tools that are created for specific purposes. Perhaps you want to control a television or a music player, or drive a remote control car. Most electronic devices have a control panel with buttons, and many of those buttons can be hacked so that you can “press” them with an Arduino. Controlling recorded sound is a good example. If you wanted to record and play back recorded sound, it would take a lot of effort to get the Arduino to do that. It’s much easier to get a small device that records and plays back sound, and replace its buttons with outputs controlled by your Arduino. Optocouplers are integrated circuits that allow you to control one circuit from a different one without any electrical connection between the two. Inside an optocoupler is an LED and a light detector. When the LED in the optocoupler is turned on by your Arduino, the light detector closes a switch internally. The switch is connected to two of the output pins (4 and 5) of the optocoupler. When the internal switch is closed, the two output pins are connected. When the switch is open, they’re not connected. This way, it’s possible to close switches on other devices without connecting them to your Arduino. Discover: optocoupler, connecting with other components Time: 45 MINUTES Builds on projects: 1,2,9 Level: HACKING BUTTONS 157
  • 3. BUILD THE CIRCUIT Fig.1 Fig.2 In this example, the diagrams are for controlling a digital recording module that allows you to record and playback 20 seconds of sound, but the basic premise holds for any device that has a switch you can access. While it’s possible to use this example without soldering any wires, it certainly makes things easier. For more information on soldering, see p. 134. 158 Project 15 Hacking Buttons
  • 4. Connect ground to your breadboard through the Arduino. Place the optocoupler on your breadboard so that it straddles the center of the board (see circuit diagram). Connect pin 1on the optocoupler to Arduino pin 2 in series with a 220-ohm resistor (remember, you’re powering an LED inside, you don’t want to burn it out). Connect pin 2 of the optocou- pler to ground. On the main board of the sound module there are a number of electrical components, including a playback button. To control the switch, you’re going to have to remove the but- ton. Flip the circuit board over and find the tabs that hold the button in place. Gently bend the tabs back and remove the but- ton from the board. Under the button are two small metal plates. This pattern is typical of many electronic devices with pushbuttons. The two “forks” of this pattern are the two sides of the switch. A small metal disc inside the pushbutton connects these two forks when you press the button. When the forks are connected, the switch is closed on the circuit board. You will be closing the switch with the optocoupler. This method, closing a switch with an optocoupler, works only if one of the two sides of the pushbutton’s switch is connected to ground on your device. If you’re not sure, take a multimeter and measure the voltage between one of the forks and the ground on your device. You need to do this with the device turned on, so be careful not to touch anywhere else on the board. Once you know which fork is ground, disconnect the power to your device. Next, connect one wire to each of the small metal plates. If you are soldering these wires, be careful to not join the two sides of the switch together. If you are not soldering and using tape, make sure your connection is secure, or the switch won’t close. Make sure neither wire connects to the other fork, or your switch will be closed all the time. Attach the two wires to pins 4 and 5 of the optocoupler. Connect the side of the switch that is grounded to pin 4 of the optocou- pler. Connect the other fork to pin 5 of the optocoupler. ❶ ❷ ❸ ❹ ❺ ❻ ❼ ❽ 159
  • 5. Most of the fun with this project is in the circuit and the optocoupler. The code is similar to the first project you made with the Arduino. You’re going to play the sound once every 20 seconds by turning pin 2 HIGH. Create a constant for the optocoupler control pin. In setup(),set the optocoupler pin into an output. The loop() turns optoPin HIGH for a few milliseconds, long enough for the optocoupler to close the switch on the device. Then the optoPin becomes LOW. Wait for 21 seconds for the whole message to play back before starting the loop() again. THE CODE Attach the battery to the sound recorder. Press and hold the record button on the device. While you’re holding the button, you can record audio into the microphone. Use your voice, the cat, or the pots and pans in the kitchen to make some noise (but be careful with the cat). Once you’ve satisfactorily recorded a sound, power your Ar- duino with the USB cable. Your recording should start to play. If you recorded for the full 20 seconds, the sound should start again just a few moments after it ends. USE IT Try experimenting with different sounds and durations of toggling the playback with the delay() in your program. If you trigger the switch while a sound is playing, it will stop. How can you take advantage of this to create unique sequences of sounds? Name a constant Configure the pin direction Pull the pin high and low Wait for a little while 160 Project 15 Hacking Buttons
  • 6. 1 const int optoPin = 2; 2 void setup(){ 3pinMode(optoPin, OUTPUT); 4 } 5 void Loop(){ 6digitaLWrite(optoPin, HIGH); 7 deLay(15); 8 digitaLWrite(optoPin, LOW); 9 deLay(21000); 10 } Integrated circuits are in virtually every electronic device. The large 28 pin chip on your Arduino is an IC that houses the brains of the board. There are other ICs that support this one with communication and power. The optocoupler and main chip on the Arduino are Dual In-line Package (DIP) chips. These DIP chips are the kind that most hobbyists use because they easily fit in a breadboard and don’t have to be per- manently soldered to be used. The project example only played sound back at a regular interval. How could you incorporate the inputs from earlier projects to trigger these sounds? What other battery powered things do you have around the house that need an Arduino to con- trol them? This technique of controlling an electronic device with an optocoupler by connecting to the two sides of a switch can be used in many other devices. What other devices do you want to control? Optocouplers can control devices that are on a different circuit.Thetwocircuitsareelectricallyseparatedfromeach otherinsidethecomponent. 161