SlideShare a Scribd company logo
Resistor-Capacitor Timing Basics 
In electronics, sometimes we want to keep a device on for a certain amount of time 
even when an electrical switch is turned off. Ordinary pushbuttons used to turn 
electronic devices on and off can easily be operated by a timed delay switch. How 
awesome would it be to create such a device to delay turning off a simple LED? Such 
a gadget could be used to trick your friends, family, or even the local Makerspace 
when they see the LED staying on after the pushbutton has been released. With a 
few electronic components from the Ultimate Microcontroller Pack, you can make 
an LED (light-emitting diode) stay on for a few extra seconds when a pushbutton 
switch is turned off. Figure 1-1 shows an assembled Trick Switch. The electronic 
components required to build the Trick Switch are shown in the Parts List. 
Parts List 
• Arduino microcontroller 
• SW1: mini pushbutton 
• LED1: red LED 
• C1: 100 uF electrolytic capacitor 
• R1: 10K ohm resistor (brown, black, orange stripes) 
• R2: 330 ohm resistor (orange, orange, brown stripes) 
• Full-size clear breadboard 
1 
The Trick Switch 1
Figure 1-1. Trick Switch circuit built on a full-size clear breadboard (both the 100 uF electrolytic 
capacitor and red LED negative pins are wired to ground) 
Tech Note 
You can create your own electrical circuits and test them using dia-grams 
with an online simulator called Circuit Lab. 
Let’s Build a Trick Switch 
When you press the pushbutton switch on this device, the LED turns on. The ca-pacitor 
will begin storing electrical energy from the +5VDC power supply circuit of 
the Arduino. Releasing the pushbutton switch cuts off the flow of electricity from 
the source, but the energy stored in the capacitor keeps the Arduino running for a 
few extra seconds. The Arduino keeps the LED lit until the capacitor’s stored energy 
is empty. You can build the Trick Switch using the electronic components from the 
Parts List and the Fritzing wiring diagram shown in Figure 1-2. Here are the steps 
required to build the electronic device: 
1. From the Ultimate Microcontroller Pack, place the required parts on your work-bench 
or lab tabletop. 
2. Wire the electronic parts using the Fritzing wiring diagram of Figure 1-2 or the 
actual Trick Switch device shown in Figure 1-1. 
2 Make: Basic Arduino Projects
3. Type the Pushbutton sketch shown in Example 1-1 into the Arduino text editor. 
4. Upload the Pushbutton sketch to the Arduino. 
5. Press the mini pushbutton for a moment. The red LED turns on. After one to 
two minutes, the red LED will turn off. 
Figure 1-2. Trick Switch Fritzing diagram 
Troubleshooting Tip 
If the Trick Switch device doesn’t work, check for incorrect resistor 
values, incorrect wiring, sketch typos, and improper orientation of 
polarized electronic components (the LED and capacitor). 
Example 1-1. Pushbutton sketch 
/* 
Pushbutton Sketch 
Reads the capacitor voltage at digital pin 2 and turns on and off a light-emitting 
diode (LED) connected to digital pin 12. 
17 Nov 2012 
Chapter 1: The Trick Switch 3
by Don Wilcher 
*/ 
// constants won't change; they're used here to 
// set pin numbers: 
const int buttonPin = 2; // the number of the pushbutton pin 
const int ledPin = 12; // the number of the LED pin 
// variables will change: 
int buttonStatus = 0; // variable for reading the pushbutton status 
void setup() { 
// initialize the LED pin as an output: 
pinMode(ledPin, OUTPUT); 
// initialize the pushbutton pin as an input: 
pinMode(buttonPin, INPUT); 
} 
void loop(){ 
// read the status of the pushbutton value: 
buttonStatus = digitalRead(buttonPin); 
// check if the pushbutton is pressed 
// if it is, the buttonEvent is HIGH: 
if (buttonStatus == HIGH) { 
// turn LED on: 
digitalWrite(ledPin, HIGH); 
} 
else { 
// turn LED off: 
digitalWrite(ledPin, LOW); 
} 
} 
Tech Note 
The ledPin value can be changed to 13 to operate the onboard LED. 
Trick Switch with On/Off Indicators 
In developing new products, electronics designers are always improving designs by 
adding features and functions that excite the customer. The Trick Switch device you 
built can be improved by adding an LED indicator. This LED indicates when the Trick 
Switch timing cycle is done. Figure 1-3 shows you where to add a green LED to the 
Trick Switch on the full-size clear breadboard. 
4 Make: Basic Arduino Projects
Figure 1-3. Adding a green LED indicator to the Trick Switch circuit built on a full-size clear 
breadboard 
To complete the new product design, you need to make a few changes to the Push-button 
sketch. Modify the sketch using the code changes shown in Example 1-2. 
Example 1-2. Pushbutton sketch modified to include LED indicators 
// constants won't change; they're used here to 
// set pin numbers: 
const int buttonPin = 2; // the number of the pushbutton pin 
const int ledPin = 12; // the number of the LED pin 
const int ledPin13 = 13; // onboard LED 
void setup() { 
// initialize the LED pins as outputs: 
pinMode(ledPin, OUTPUT); 
pinMode(ledPin13, OUTPUT); 
// initialize the pushbutton pin as an input: 
pinMode(buttonPin, INPUT); 
} 
void loop(){ 
// read the state of the pushbutton value: 
int buttonStatus; 
buttonStatus = digitalRead(buttonPin); 
// check if the pushbutton is pressed 
// if it is, the buttonStatus is HIGH: 
if (buttonStatus == HIGH) { 
Chapter 1: The Trick Switch 5
// turn LED on: 
digitalWrite(ledPin, HIGH); 
// turn off onboard LED: 
digitalWrite(ledPin13,LOW); 
} 
else { 
// turn LED off: 
digitalWrite(ledPin, LOW); 
// turn on onboard LED: 
digitalWrite(ledPin13, HIGH); 
} 
} 
After you’ve saved the sketch changes and uploaded them to the Arduino, the green 
LED will turn on. When you press the mini pushbutton, the green LED will turn off, 
and the red LED will turn on. Pretty awesome stuff. Enjoy! 
The block diagram in Figure 1-4 shows the electronic component blocks and the 
electrical signal flow for the Trick Switch. A Fritzing electronic circuit schematic di-agram 
of the switch is shown in Figure 1-5. Electronic circuit schematic diagrams 
are used by electrical/electronic engineers to design and build cool electronic prod-ucts 
for society. 
Figure 1-4. Trick Switch block diagram 
Something to Think About 
Try different resistor and capacitor values and see what happens. Can you detect 
any patterns? How can a small piezo buzzer be used with the Trick Switch? 
6 Make: Basic Arduino Projects
Figure 1-5. Trick Switch circuit schematic diagram 
Chapter 1: The Trick Switch 7

More Related Content

What's hot

What Is Magnetic Contactor
What Is Magnetic ContactorWhat Is Magnetic Contactor
What Is Magnetic Contactor
Emran Hosain
 
Informe practico
Informe practicoInforme practico
Informe practico
Daya CaRol Hrnn
 
Ladder logic tutorial
Ladder logic tutorialLadder logic tutorial
Ladder logic tutorial
das1964
 
Practica de la luz nocturna y la punta logica.
Practica de la luz nocturna y la punta logica.Practica de la luz nocturna y la punta logica.
Practica de la luz nocturna y la punta logica.
rinnery
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
aditya806802
 
Plc Basics
Plc BasicsPlc Basics
Fuentes de alimentacion
Fuentes de alimentacionFuentes de alimentacion
Fuentes de alimentacion
rseclen_b
 
Modulpraktikum dasar instalasi listrik
Modulpraktikum dasar instalasi listrikModulpraktikum dasar instalasi listrik
Modulpraktikum dasar instalasi listrik
Simon Patabang
 
Automatic Phase Changer
Automatic Phase ChangerAutomatic Phase Changer
Automatic Phase Changer
Bhanu Bhawesh
 
Belajar bahasa ladder diagram plc
Belajar bahasa ladder diagram plcBelajar bahasa ladder diagram plc
Belajar bahasa ladder diagram plc
Arman Tan
 
PresentacióN ReléS I
PresentacióN ReléS IPresentacióN ReléS I
PresentacióN ReléS I
Royer García
 
Gambar teknik elektronika
Gambar teknik elektronikaGambar teknik elektronika
Gambar teknik elektronika
PT.goLom na
 
Automatic fan controller based on room temperature
Automatic fan controller based on room temperatureAutomatic fan controller based on room temperature
Automatic fan controller based on room temperature
nikhilreddy411
 
Hobetuz domotica 1 - Logo Siemens
Hobetuz   domotica 1 - Logo SiemensHobetuz   domotica 1 - Logo Siemens
Hobetuz domotica 1 - Logo Siemens
xendika2
 
Report Home automation using arduino
Report Home automation using arduinoReport Home automation using arduino
Report Home automation using arduino
Ikram Arshad
 
Instalación electrica basica
Instalación electrica basicaInstalación electrica basica
Instalación electrica basica
angelza23
 
Electronics part 10 electronics elements , applications of bjt bipolar junc...
Electronics part 10 electronics elements ,  applications of  bjt bipolar junc...Electronics part 10 electronics elements ,  applications of  bjt bipolar junc...
Electronics part 10 electronics elements , applications of bjt bipolar junc...
Osama Ghandour Geris
 
programmable logical controller(PLC)
programmable logical controller(PLC)programmable logical controller(PLC)
programmable logical controller(PLC)
hemadri sharma
 
intalaciones electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELS
intalaciones  electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELSintalaciones  electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELS
intalaciones electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELS
Ronald Paytan Huamani
 
02 02 El Contactor
02 02 El Contactor02 02 El Contactor
02 02 El Contactor
F Blanco
 

What's hot (20)

What Is Magnetic Contactor
What Is Magnetic ContactorWhat Is Magnetic Contactor
What Is Magnetic Contactor
 
Informe practico
Informe practicoInforme practico
Informe practico
 
Ladder logic tutorial
Ladder logic tutorialLadder logic tutorial
Ladder logic tutorial
 
Practica de la luz nocturna y la punta logica.
Practica de la luz nocturna y la punta logica.Practica de la luz nocturna y la punta logica.
Practica de la luz nocturna y la punta logica.
 
home automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasadhome automation using Arduino by Aditya Prasad
home automation using Arduino by Aditya Prasad
 
Plc Basics
Plc BasicsPlc Basics
Plc Basics
 
Fuentes de alimentacion
Fuentes de alimentacionFuentes de alimentacion
Fuentes de alimentacion
 
Modulpraktikum dasar instalasi listrik
Modulpraktikum dasar instalasi listrikModulpraktikum dasar instalasi listrik
Modulpraktikum dasar instalasi listrik
 
Automatic Phase Changer
Automatic Phase ChangerAutomatic Phase Changer
Automatic Phase Changer
 
Belajar bahasa ladder diagram plc
Belajar bahasa ladder diagram plcBelajar bahasa ladder diagram plc
Belajar bahasa ladder diagram plc
 
PresentacióN ReléS I
PresentacióN ReléS IPresentacióN ReléS I
PresentacióN ReléS I
 
Gambar teknik elektronika
Gambar teknik elektronikaGambar teknik elektronika
Gambar teknik elektronika
 
Automatic fan controller based on room temperature
Automatic fan controller based on room temperatureAutomatic fan controller based on room temperature
Automatic fan controller based on room temperature
 
Hobetuz domotica 1 - Logo Siemens
Hobetuz   domotica 1 - Logo SiemensHobetuz   domotica 1 - Logo Siemens
Hobetuz domotica 1 - Logo Siemens
 
Report Home automation using arduino
Report Home automation using arduinoReport Home automation using arduino
Report Home automation using arduino
 
Instalación electrica basica
Instalación electrica basicaInstalación electrica basica
Instalación electrica basica
 
Electronics part 10 electronics elements , applications of bjt bipolar junc...
Electronics part 10 electronics elements ,  applications of  bjt bipolar junc...Electronics part 10 electronics elements ,  applications of  bjt bipolar junc...
Electronics part 10 electronics elements , applications of bjt bipolar junc...
 
programmable logical controller(PLC)
programmable logical controller(PLC)programmable logical controller(PLC)
programmable logical controller(PLC)
 
intalaciones electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELS
intalaciones  electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELSintalaciones  electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELS
intalaciones electricas - UNIVERSIDAD NACIONAL TECNOLOGICA DE LIMA SUR UNTELS
 
02 02 El Contactor
02 02 El Contactor02 02 El Contactor
02 02 El Contactor
 

Similar to Arduino - CH 1: The Trick Switch

Electronz_Chapter_2.pptx
Electronz_Chapter_2.pptxElectronz_Chapter_2.pptx
Electronz_Chapter_2.pptx
Mokete5
 
How to hack electronics
How to hack electronics How to hack electronics
How to hack electronics
Planning-ness
 
Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbook
Felipe Belarmino
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ajit kumar singh
 
Basic arduino sketch example
Basic arduino sketch exampleBasic arduino sketch example
Basic arduino sketch example
mraziff2009
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
Electric&elctronics&engineeering
 
Arduino
ArduinoArduino
Arduino
Geet Patel
 
publish manual
publish manualpublish manual
publish manual
John Webster
 
Infrared Temperature Pen
Infrared Temperature PenInfrared Temperature Pen
Infrared Temperature Pen
Charlie Aylward
 
Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2
Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2
Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2
SANTIAGO PABLO ALBERTO
 
Robotics Session day 1
Robotics Session day 1Robotics Session day 1
Robotics Session day 1
Afzal Ahmad
 
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
DO!MAKERS
 
home automation digital
home automation digitalhome automation digital
home automation digital
Shishupal03012015
 
Arduino workshop sensors
Arduino workshop sensorsArduino workshop sensors
Arduino workshop sensors
Jhonny Wladimir Peñaloza Cabello
 
LEDs and DIPs Switches
LEDs and DIPs SwitchesLEDs and DIPs Switches
LEDs and DIPs Switches
Bach Nguyen
 
water level edit.docx
water level edit.docxwater level edit.docx
water level edit.docx
MdAhasanHabibLabu
 
IoT Basics with few Embedded System Connections for sensors
IoT Basics with few Embedded System Connections for sensorsIoT Basics with few Embedded System Connections for sensors
IoT Basics with few Embedded System Connections for sensors
saritasapkal
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
Dhruwank Vankawala
 
Udayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptxUdayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptx
Syncrotrone
 

Similar to Arduino - CH 1: The Trick Switch (20)

Electronz_Chapter_2.pptx
Electronz_Chapter_2.pptxElectronz_Chapter_2.pptx
Electronz_Chapter_2.pptx
 
How to hack electronics
How to hack electronics How to hack electronics
How to hack electronics
 
Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbook
 
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY ARDUINO BASED TIME AND TEMPERATURE DISPLAY
ARDUINO BASED TIME AND TEMPERATURE DISPLAY
 
Basic arduino sketch example
Basic arduino sketch exampleBasic arduino sketch example
Basic arduino sketch example
 
Bidirect visitor counter
Bidirect visitor counterBidirect visitor counter
Bidirect visitor counter
 
Arduino
ArduinoArduino
Arduino
 
publish manual
publish manualpublish manual
publish manual
 
Infrared Temperature Pen
Infrared Temperature PenInfrared Temperature Pen
Infrared Temperature Pen
 
Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2
Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2
Arduino: Arduino para dummies 2 edición por Wiley Brand parte 2
 
Robotics Session day 1
Robotics Session day 1Robotics Session day 1
Robotics Session day 1
 
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
 
home automation digital
home automation digitalhome automation digital
home automation digital
 
Arduino workshop sensors
Arduino workshop sensorsArduino workshop sensors
Arduino workshop sensors
 
LEDs and DIPs Switches
LEDs and DIPs SwitchesLEDs and DIPs Switches
LEDs and DIPs Switches
 
water level edit.docx
water level edit.docxwater level edit.docx
water level edit.docx
 
IoT Basics with few Embedded System Connections for sensors
IoT Basics with few Embedded System Connections for sensorsIoT Basics with few Embedded System Connections for sensors
IoT Basics with few Embedded System Connections for sensors
 
Embedded system application
Embedded system applicationEmbedded system application
Embedded system application
 
Udayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptxUdayan_219209024_DA1001_FTP.pptx
Udayan_219209024_DA1001_FTP.pptx
 

More from Ratzman III

Tugas Tutorial EKSI4202 Hukum Pajak
Tugas Tutorial EKSI4202 Hukum PajakTugas Tutorial EKSI4202 Hukum Pajak
Tugas Tutorial EKSI4202 Hukum Pajak
Ratzman III
 
Tugas Wajib Tutorial I - EKSI4202 - Hukum Pajak
Tugas Wajib Tutorial I  -  EKSI4202 - Hukum PajakTugas Wajib Tutorial I  -  EKSI4202 - Hukum Pajak
Tugas Wajib Tutorial I - EKSI4202 - Hukum PajakRatzman III
 
Review Artikel Tinjauan Pustaka
Review Artikel Tinjauan PustakaReview Artikel Tinjauan Pustaka
Review Artikel Tinjauan Pustaka
Ratzman III
 
MICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya Ilmiah
MICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya IlmiahMICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya Ilmiah
MICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya Ilmiah
Ratzman III
 
Format laporan Tutor Universitas Terbuka 2014
Format laporan Tutor Universitas Terbuka 2014Format laporan Tutor Universitas Terbuka 2014
Format laporan Tutor Universitas Terbuka 2014
Ratzman III
 
Bab 3 - Kalkulus Relasional
Bab 3 -  Kalkulus RelasionalBab 3 -  Kalkulus Relasional
Bab 3 - Kalkulus Relasional
Ratzman III
 
Bab 2 Aljabar Relasional
Bab 2   Aljabar RelasionalBab 2   Aljabar Relasional
Bab 2 Aljabar Relasional
Ratzman III
 
Bab 1 RDBMS Review
Bab 1   RDBMS ReviewBab 1   RDBMS Review
Bab 1 RDBMS Review
Ratzman III
 
Kisi kisi basis data uts
Kisi kisi basis data utsKisi kisi basis data uts
Kisi kisi basis data utsRatzman III
 
Kisi kisi basis data uts
Kisi kisi basis data utsKisi kisi basis data uts
Kisi kisi basis data uts
Ratzman III
 
Modul my sql tutorial part 6
Modul my sql tutorial part 6Modul my sql tutorial part 6
Modul my sql tutorial part 6Ratzman III
 
Tugas i
Tugas iTugas i
Tugas i
Ratzman III
 
Modul my sql tutorial part 5
Modul my sql tutorial part 5Modul my sql tutorial part 5
Modul my sql tutorial part 5Ratzman III
 
Pengabdian 2
Pengabdian 2Pengabdian 2
Pengabdian 2
Ratzman III
 
Format Pengabdian Masyarakat
Format Pengabdian MasyarakatFormat Pengabdian Masyarakat
Format Pengabdian Masyarakat
Ratzman III
 
Format makalah knsi 2013
Format makalah knsi 2013Format makalah knsi 2013
Format makalah knsi 2013Ratzman III
 

More from Ratzman III (20)

Tugas Tutorial EKSI4202 Hukum Pajak
Tugas Tutorial EKSI4202 Hukum PajakTugas Tutorial EKSI4202 Hukum Pajak
Tugas Tutorial EKSI4202 Hukum Pajak
 
Tugas Wajib Tutorial I - EKSI4202 - Hukum Pajak
Tugas Wajib Tutorial I  -  EKSI4202 - Hukum PajakTugas Wajib Tutorial I  -  EKSI4202 - Hukum Pajak
Tugas Wajib Tutorial I - EKSI4202 - Hukum Pajak
 
Review Artikel Tinjauan Pustaka
Review Artikel Tinjauan PustakaReview Artikel Tinjauan Pustaka
Review Artikel Tinjauan Pustaka
 
MICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya Ilmiah
MICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya IlmiahMICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya Ilmiah
MICRO TEACHING IDIK4013-Memanfaatkan Pustaka dalam Penulisan Karya Ilmiah
 
Format laporan Tutor Universitas Terbuka 2014
Format laporan Tutor Universitas Terbuka 2014Format laporan Tutor Universitas Terbuka 2014
Format laporan Tutor Universitas Terbuka 2014
 
Bab 3 - Kalkulus Relasional
Bab 3 -  Kalkulus RelasionalBab 3 -  Kalkulus Relasional
Bab 3 - Kalkulus Relasional
 
Bab 2 Aljabar Relasional
Bab 2   Aljabar RelasionalBab 2   Aljabar Relasional
Bab 2 Aljabar Relasional
 
Bab 1 RDBMS Review
Bab 1   RDBMS ReviewBab 1   RDBMS Review
Bab 1 RDBMS Review
 
Kisi kisi basis data uts
Kisi kisi basis data utsKisi kisi basis data uts
Kisi kisi basis data uts
 
Kisi kisi basis data uts
Kisi kisi basis data utsKisi kisi basis data uts
Kisi kisi basis data uts
 
Modul my sql tutorial part 6
Modul my sql tutorial part 6Modul my sql tutorial part 6
Modul my sql tutorial part 6
 
Nilai lab 01pt3
Nilai lab 01pt3Nilai lab 01pt3
Nilai lab 01pt3
 
Format sap
Format sapFormat sap
Format sap
 
Tugas i
Tugas iTugas i
Tugas i
 
Modul my sql tutorial part 5
Modul my sql tutorial part 5Modul my sql tutorial part 5
Modul my sql tutorial part 5
 
1088
10881088
1088
 
1152
11521152
1152
 
Pengabdian 2
Pengabdian 2Pengabdian 2
Pengabdian 2
 
Format Pengabdian Masyarakat
Format Pengabdian MasyarakatFormat Pengabdian Masyarakat
Format Pengabdian Masyarakat
 
Format makalah knsi 2013
Format makalah knsi 2013Format makalah knsi 2013
Format makalah knsi 2013
 

Recently uploaded

مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
Nguyen Thanh Tu Collection
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
Nguyen Thanh Tu Collection
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
iammrhaywood
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
BoudhayanBhattachari
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
EduSkills OECD
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
PsychoTech Services
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
TechSoup
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 

Recently uploaded (20)

مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
BÀI TẬP DẠY THÊM TIẾNG ANH LỚP 7 CẢ NĂM FRIENDS PLUS SÁCH CHÂN TRỜI SÁNG TẠO ...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 9 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2024-2025 - ...
 
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptxNEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
NEWSPAPERS - QUESTION 1 - REVISION POWERPOINT.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
B. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdfB. Ed Syllabus for babasaheb ambedkar education university.pdf
B. Ed Syllabus for babasaheb ambedkar education university.pdf
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxBeyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptx
 
Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...Gender and Mental Health - Counselling and Family Therapy Applications and In...
Gender and Mental Health - Counselling and Family Therapy Applications and In...
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
Leveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit InnovationLeveraging Generative AI to Drive Nonprofit Innovation
Leveraging Generative AI to Drive Nonprofit Innovation
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 

Arduino - CH 1: The Trick Switch

  • 1.
  • 2. Resistor-Capacitor Timing Basics In electronics, sometimes we want to keep a device on for a certain amount of time even when an electrical switch is turned off. Ordinary pushbuttons used to turn electronic devices on and off can easily be operated by a timed delay switch. How awesome would it be to create such a device to delay turning off a simple LED? Such a gadget could be used to trick your friends, family, or even the local Makerspace when they see the LED staying on after the pushbutton has been released. With a few electronic components from the Ultimate Microcontroller Pack, you can make an LED (light-emitting diode) stay on for a few extra seconds when a pushbutton switch is turned off. Figure 1-1 shows an assembled Trick Switch. The electronic components required to build the Trick Switch are shown in the Parts List. Parts List • Arduino microcontroller • SW1: mini pushbutton • LED1: red LED • C1: 100 uF electrolytic capacitor • R1: 10K ohm resistor (brown, black, orange stripes) • R2: 330 ohm resistor (orange, orange, brown stripes) • Full-size clear breadboard 1 The Trick Switch 1
  • 3. Figure 1-1. Trick Switch circuit built on a full-size clear breadboard (both the 100 uF electrolytic capacitor and red LED negative pins are wired to ground) Tech Note You can create your own electrical circuits and test them using dia-grams with an online simulator called Circuit Lab. Let’s Build a Trick Switch When you press the pushbutton switch on this device, the LED turns on. The ca-pacitor will begin storing electrical energy from the +5VDC power supply circuit of the Arduino. Releasing the pushbutton switch cuts off the flow of electricity from the source, but the energy stored in the capacitor keeps the Arduino running for a few extra seconds. The Arduino keeps the LED lit until the capacitor’s stored energy is empty. You can build the Trick Switch using the electronic components from the Parts List and the Fritzing wiring diagram shown in Figure 1-2. Here are the steps required to build the electronic device: 1. From the Ultimate Microcontroller Pack, place the required parts on your work-bench or lab tabletop. 2. Wire the electronic parts using the Fritzing wiring diagram of Figure 1-2 or the actual Trick Switch device shown in Figure 1-1. 2 Make: Basic Arduino Projects
  • 4. 3. Type the Pushbutton sketch shown in Example 1-1 into the Arduino text editor. 4. Upload the Pushbutton sketch to the Arduino. 5. Press the mini pushbutton for a moment. The red LED turns on. After one to two minutes, the red LED will turn off. Figure 1-2. Trick Switch Fritzing diagram Troubleshooting Tip If the Trick Switch device doesn’t work, check for incorrect resistor values, incorrect wiring, sketch typos, and improper orientation of polarized electronic components (the LED and capacitor). Example 1-1. Pushbutton sketch /* Pushbutton Sketch Reads the capacitor voltage at digital pin 2 and turns on and off a light-emitting diode (LED) connected to digital pin 12. 17 Nov 2012 Chapter 1: The Trick Switch 3
  • 5. by Don Wilcher */ // constants won't change; they're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 12; // the number of the LED pin // variables will change: int buttonStatus = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the status of the pushbutton value: buttonStatus = digitalRead(buttonPin); // check if the pushbutton is pressed // if it is, the buttonEvent is HIGH: if (buttonStatus == HIGH) { // turn LED on: digitalWrite(ledPin, HIGH); } else { // turn LED off: digitalWrite(ledPin, LOW); } } Tech Note The ledPin value can be changed to 13 to operate the onboard LED. Trick Switch with On/Off Indicators In developing new products, electronics designers are always improving designs by adding features and functions that excite the customer. The Trick Switch device you built can be improved by adding an LED indicator. This LED indicates when the Trick Switch timing cycle is done. Figure 1-3 shows you where to add a green LED to the Trick Switch on the full-size clear breadboard. 4 Make: Basic Arduino Projects
  • 6. Figure 1-3. Adding a green LED indicator to the Trick Switch circuit built on a full-size clear breadboard To complete the new product design, you need to make a few changes to the Push-button sketch. Modify the sketch using the code changes shown in Example 1-2. Example 1-2. Pushbutton sketch modified to include LED indicators // constants won't change; they're used here to // set pin numbers: const int buttonPin = 2; // the number of the pushbutton pin const int ledPin = 12; // the number of the LED pin const int ledPin13 = 13; // onboard LED void setup() { // initialize the LED pins as outputs: pinMode(ledPin, OUTPUT); pinMode(ledPin13, OUTPUT); // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); } void loop(){ // read the state of the pushbutton value: int buttonStatus; buttonStatus = digitalRead(buttonPin); // check if the pushbutton is pressed // if it is, the buttonStatus is HIGH: if (buttonStatus == HIGH) { Chapter 1: The Trick Switch 5
  • 7. // turn LED on: digitalWrite(ledPin, HIGH); // turn off onboard LED: digitalWrite(ledPin13,LOW); } else { // turn LED off: digitalWrite(ledPin, LOW); // turn on onboard LED: digitalWrite(ledPin13, HIGH); } } After you’ve saved the sketch changes and uploaded them to the Arduino, the green LED will turn on. When you press the mini pushbutton, the green LED will turn off, and the red LED will turn on. Pretty awesome stuff. Enjoy! The block diagram in Figure 1-4 shows the electronic component blocks and the electrical signal flow for the Trick Switch. A Fritzing electronic circuit schematic di-agram of the switch is shown in Figure 1-5. Electronic circuit schematic diagrams are used by electrical/electronic engineers to design and build cool electronic prod-ucts for society. Figure 1-4. Trick Switch block diagram Something to Think About Try different resistor and capacitor values and see what happens. Can you detect any patterns? How can a small piezo buzzer be used with the Trick Switch? 6 Make: Basic Arduino Projects
  • 8. Figure 1-5. Trick Switch circuit schematic diagram Chapter 1: The Trick Switch 7