SlideShare a Scribd company logo
1 of 15
Download to read offline
Push button Switch
1
Push button Switch
Switches are really simple components. When you press a
button or flip a lever, they connect two contacts together so
that electricity can flow through them.
The little tactile switches that are used in our example have
four connections, which can be a little confusing.
2
Push button Switch
Actually, there are only really two electrical connections, as
inside the switch package pins B and C are connected
together, as are A and D.
3
Push button Switch
To build such application, you will need the
following Components:
• Arduino Uno
• USB cable
• Push Switch
• Jumper Wires
• LED
• Resistor
4
Push button –Without Code
5
Push button –With Code
int d=2; // to store on or off value
void setup()
{pinMode(2,INPUT);
pinMode(13,OUTPUT);
}
void loop()
{
d=digitalRead(2);
if(d==0)
{digitalWrite(13,HIGH);}
else
{digitalWrite(13,LOW);}
}
6
Keypad
7
Keypad
Keypads are used in all types of devices, including
cell phones, fax machines, microwaves, ovens,
door locks, etc. They're practically everywhere.
electronic devices use them for user input. So
knowing how to connect a keypad to a
microcontroller such as an Arduino is very
valuable for building many different types of
commercial products.
when a key is pressed, it show up at the Serial
Monitor on your computer. For this project, the
type of keypad we will use is a matrix keypad. The
matrix keypad we are using has 16 keys (0-9, A-D,
*, #), yet only 8 output pins.
8
Keypad
How the rows and column are
arranged inside the keypad is
shown in the figure.
The Arduino can determine
which button was pressed.
For example, when key 1 is
pressed, column 1 and row 1
are shorted. The Arduino will
detect that and input a 1 to the
program.
9
R1
R2
R3
R4
C1 C2 C3 C4
R1 R2 R3R4C1C2 C3C4
Keypad
To build such application, you need the following
components:
• Arduino Uno
• USB cable
• 4x4 Matrix Keypad
• Jumper wires
10
Keypad
11
Keypad with Arduino Uno connections:
Keypad
#include <Keypad.h>
const byte numRows= 4; //number of rows on the keypad
const byte numCols= 4; //number of columns on the keypad
//keymap defines the key pressed according to the row and columns
//just as appears on the keypad
char keymap[numRows][numCols]=
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
12
Keypad
//Code that shows the keypad connections to the arduino terminals
byte rowPins[numRows] = {9,8,7,6}; //Rows 0 to 3
byte colPins[numCols]= {5,4,3,2}; //Columns 0 to 3
//initializes an instance of the Keypad class
Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins,
colPins, numRows, numCols);
void setup()
{
Serial.begin(9600);
}
13
Keypad
//If key is pressed, this key is stored in 'keypressed' variable
//If key is not equal to 'NO_KEY', then this key is printed out
//if count=17, then count is reset back to 0 (this means no key is
//pressed during the whole keypad scan process
void loop()
{
char keypressed = myKeypad.getKey();
if (keypressed != NO_KEY)
{
Serial.print(keypressed);
}
}
}
14
15

More Related Content

What's hot

What's hot (7)

Arduino lec 4
Arduino lec 4 Arduino lec 4
Arduino lec 4
 
Wireless and wired controllers for nintendo switch
Wireless and wired controllers for nintendo switchWireless and wired controllers for nintendo switch
Wireless and wired controllers for nintendo switch
 
Arduino lec 1
Arduino lec 1Arduino lec 1
Arduino lec 1
 
Arduino
ArduinoArduino
Arduino
 
Robotics Session day 1
Robotics Session day 1Robotics Session day 1
Robotics Session day 1
 
Arduino boards
Arduino boardsArduino boards
Arduino boards
 
Computer Parts
Computer PartsComputer Parts
Computer Parts
 

Similar to Arduino based Applications-part 6

Similar to Arduino based Applications-part 6 (20)

Arduino electronics cookbook
Arduino electronics cookbookArduino electronics cookbook
Arduino electronics cookbook
 
arduino.ppt
arduino.pptarduino.ppt
arduino.ppt
 
Arduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick SwitchArduino - CH 1: The Trick Switch
Arduino - CH 1: The Trick Switch
 
Ard ui no fire alarm system
Ard ui no fire alarm systemArd ui no fire alarm system
Ard ui no fire alarm system
 
Fun with arduino
Fun with arduinoFun with arduino
Fun with arduino
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
arduinoSimon.ppt
arduinoSimon.pptarduinoSimon.ppt
arduinoSimon.ppt
 
Remote ashok
Remote ashokRemote ashok
Remote ashok
 
Camden 120TX Instruction Manual
Camden 120TX Instruction ManualCamden 120TX Instruction Manual
Camden 120TX Instruction Manual
 
Arduino
ArduinoArduino
Arduino
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Camden 120W-V2 Instruction Manual
Camden 120W-V2 Instruction ManualCamden 120W-V2 Instruction Manual
Camden 120W-V2 Instruction Manual
 
Automatic room light controller with visible counter
Automatic room light controller with visible counterAutomatic room light controller with visible counter
Automatic room light controller with visible counter
 
How to hack electronics
How to hack electronics How to hack electronics
How to hack electronics
 
IOT ARDUINO UNO.pptx
IOT ARDUINO UNO.pptxIOT ARDUINO UNO.pptx
IOT ARDUINO UNO.pptx
 
publish manual
publish manualpublish manual
publish manual
 
Electronz_Chapter_15.pptx
Electronz_Chapter_15.pptxElectronz_Chapter_15.pptx
Electronz_Chapter_15.pptx
 
Arduino Programming Basic
Arduino Programming BasicArduino Programming Basic
Arduino Programming Basic
 

More from Jawaher Abdulwahab Fadhil

More from Jawaher Abdulwahab Fadhil (20)

Binary adder
Binary adderBinary adder
Binary adder
 
Number system
Number systemNumber system
Number system
 
Add instruction-part1
Add instruction-part1Add instruction-part1
Add instruction-part1
 
Dealing with 8086 memory
Dealing with 8086 memoryDealing with 8086 memory
Dealing with 8086 memory
 
MOV instruction part1
MOV  instruction part1MOV  instruction part1
MOV instruction part1
 
Cisco webex installation guide
Cisco webex installation guideCisco webex installation guide
Cisco webex installation guide
 
A survey on the applications of smart home
A survey on the applications of smart homeA survey on the applications of smart home
A survey on the applications of smart home
 
Flag register and add instruction
Flag register and  add instructionFlag register and  add instruction
Flag register and add instruction
 
Computer Organization -part 1
Computer Organization -part 1Computer Organization -part 1
Computer Organization -part 1
 
iOS Operating System
iOS Operating SystemiOS Operating System
iOS Operating System
 
Android Operating system
Android Operating systemAndroid Operating system
Android Operating system
 
Types of Mobile Applications
Types of Mobile ApplicationsTypes of Mobile Applications
Types of Mobile Applications
 
Ultrasonic with buzzer
Ultrasonic with buzzerUltrasonic with buzzer
Ultrasonic with buzzer
 
Lecture6 modulation
Lecture6 modulationLecture6 modulation
Lecture6 modulation
 
Lecture 5: The Convolution Sum
Lecture 5: The Convolution SumLecture 5: The Convolution Sum
Lecture 5: The Convolution Sum
 
Lecture 4: Classification of system
Lecture 4: Classification of system Lecture 4: Classification of system
Lecture 4: Classification of system
 
Lecture3: Operations of Ct signals
Lecture3: Operations of Ct signalsLecture3: Operations of Ct signals
Lecture3: Operations of Ct signals
 
Lecture2 : Common continuous time signals
Lecture2 : Common continuous time signalsLecture2 : Common continuous time signals
Lecture2 : Common continuous time signals
 
Lecture1: Introduction to signals
Lecture1: Introduction to signalsLecture1: Introduction to signals
Lecture1: Introduction to signals
 
Arduino- Serial communication
Arduino-  Serial communicationArduino-  Serial communication
Arduino- Serial communication
 

Recently uploaded

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 

Recently uploaded (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 

Arduino based Applications-part 6

  • 2. Push button Switch Switches are really simple components. When you press a button or flip a lever, they connect two contacts together so that electricity can flow through them. The little tactile switches that are used in our example have four connections, which can be a little confusing. 2
  • 3. Push button Switch Actually, there are only really two electrical connections, as inside the switch package pins B and C are connected together, as are A and D. 3
  • 4. Push button Switch To build such application, you will need the following Components: • Arduino Uno • USB cable • Push Switch • Jumper Wires • LED • Resistor 4
  • 6. Push button –With Code int d=2; // to store on or off value void setup() {pinMode(2,INPUT); pinMode(13,OUTPUT); } void loop() { d=digitalRead(2); if(d==0) {digitalWrite(13,HIGH);} else {digitalWrite(13,LOW);} } 6
  • 8. Keypad Keypads are used in all types of devices, including cell phones, fax machines, microwaves, ovens, door locks, etc. They're practically everywhere. electronic devices use them for user input. So knowing how to connect a keypad to a microcontroller such as an Arduino is very valuable for building many different types of commercial products. when a key is pressed, it show up at the Serial Monitor on your computer. For this project, the type of keypad we will use is a matrix keypad. The matrix keypad we are using has 16 keys (0-9, A-D, *, #), yet only 8 output pins. 8
  • 9. Keypad How the rows and column are arranged inside the keypad is shown in the figure. The Arduino can determine which button was pressed. For example, when key 1 is pressed, column 1 and row 1 are shorted. The Arduino will detect that and input a 1 to the program. 9 R1 R2 R3 R4 C1 C2 C3 C4 R1 R2 R3R4C1C2 C3C4
  • 10. Keypad To build such application, you need the following components: • Arduino Uno • USB cable • 4x4 Matrix Keypad • Jumper wires 10
  • 11. Keypad 11 Keypad with Arduino Uno connections:
  • 12. Keypad #include <Keypad.h> const byte numRows= 4; //number of rows on the keypad const byte numCols= 4; //number of columns on the keypad //keymap defines the key pressed according to the row and columns //just as appears on the keypad char keymap[numRows][numCols]= { {'1', '2', '3', 'A'}, {'4', '5', '6', 'B'}, {'7', '8', '9', 'C'}, {'*', '0', '#', 'D'} }; 12
  • 13. Keypad //Code that shows the keypad connections to the arduino terminals byte rowPins[numRows] = {9,8,7,6}; //Rows 0 to 3 byte colPins[numCols]= {5,4,3,2}; //Columns 0 to 3 //initializes an instance of the Keypad class Keypad myKeypad= Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols); void setup() { Serial.begin(9600); } 13
  • 14. Keypad //If key is pressed, this key is stored in 'keypressed' variable //If key is not equal to 'NO_KEY', then this key is printed out //if count=17, then count is reset back to 0 (this means no key is //pressed during the whole keypad scan process void loop() { char keypressed = myKeypad.getKey(); if (keypressed != NO_KEY) { Serial.print(keypressed); } } } 14
  • 15. 15