SlideShare a Scribd company logo
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

PDF
Arduino
DOCX
Voice_based_HA
PPTX
Embedded systems presentation
PDF
Arduino workshop sensors
PDF
Saur lecture 16
DOCX
Call and message using arduino and gsm module
PPTX
Arduino lec 3
PPT
COMPUTER ORGANIZATION -Multiplexer,Demultiplexer, Encoder
Arduino
Voice_based_HA
Embedded systems presentation
Arduino workshop sensors
Saur lecture 16
Call and message using arduino and gsm module
Arduino lec 3
COMPUTER ORGANIZATION -Multiplexer,Demultiplexer, Encoder

What's hot (7)

PPTX
Arduino lec 4
PPTX
Wireless and wired controllers for nintendo switch
PPTX
Arduino lec 1
ODP
Arduino
PPTX
Robotics Session day 1
ODP
Arduino boards
PPTX
Computer Parts
Arduino lec 4
Wireless and wired controllers for nintendo switch
Arduino lec 1
Arduino
Robotics Session day 1
Arduino boards
Computer Parts
Ad

Similar to Arduino based Applications-part 6 (20)

PPT
Presentation2 1-150523155048-lva1-app6892
DOCX
Keypad interfacing 8051 -NANOCDAC
PPTX
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
PPTX
Final Presentation
PPT
Lcd & keypad
DOCX
Password based door locksystem
PPTX
Magnetic door lock using arduino
PPTX
Arduino Programming
PPT
Microprocessors Practical Examination.ppt
PPTX
Keyboard Interfacing .pptx
PDF
Edge_AI_Assignment_3.pdf
PDF
Keypad Interfacing with 8051 Microcontroller
PPTX
Electronz_Chapter_7.pptx
DOCX
PPTX
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
PPTX
Smart Safety Door based on Arduino Uno R3
PDF
LCD Keypad Shield
PPT
Interfacing keypad
PPTX
Porte à puce - Smart Safety Door based on Arduino UNO R3
PDF
Input interface with Raspberry pi
Presentation2 1-150523155048-lva1-app6892
Keypad interfacing 8051 -NANOCDAC
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Final Presentation
Lcd & keypad
Password based door locksystem
Magnetic door lock using arduino
Arduino Programming
Microprocessors Practical Examination.ppt
Keyboard Interfacing .pptx
Edge_AI_Assignment_3.pdf
Keypad Interfacing with 8051 Microcontroller
Electronz_Chapter_7.pptx
Smart Safety Door with Servo Motors as Actuators, Passcode and DHT Sensors B...
Smart Safety Door based on Arduino Uno R3
LCD Keypad Shield
Interfacing keypad
Porte à puce - Smart Safety Door based on Arduino UNO R3
Input interface with Raspberry pi
Ad

More from Jawaher Abdulwahab Fadhil (20)

PDF
PPT
PDF
Add instruction-part1
PPTX
Dealing with 8086 memory
PPTX
MOV instruction part1
PDF
Cisco webex installation guide
PPTX
A survey on the applications of smart home
PPT
Flag register and add instruction
PDF
Computer Organization -part 1
PPTX
iOS Operating System
PPTX
Android Operating system
PPTX
Types of Mobile Applications
PDF
Ultrasonic with buzzer
PDF
Lecture6 modulation
PDF
Lecture 5: The Convolution Sum
PDF
Lecture 4: Classification of system
PDF
Lecture3: Operations of Ct signals
PDF
Lecture2 : Common continuous time signals
PDF
Lecture1: Introduction to signals
PDF
Arduino- Serial communication
Add instruction-part1
Dealing with 8086 memory
MOV instruction part1
Cisco webex installation guide
A survey on the applications of smart home
Flag register and add instruction
Computer Organization -part 1
iOS Operating System
Android Operating system
Types of Mobile Applications
Ultrasonic with buzzer
Lecture6 modulation
Lecture 5: The Convolution Sum
Lecture 4: Classification of system
Lecture3: Operations of Ct signals
Lecture2 : Common continuous time signals
Lecture1: Introduction to signals
Arduino- Serial communication

Recently uploaded (20)

PDF
TR - Agricultural Crops Production NC III.pdf
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Complications of Minimal Access Surgery at WLH
PDF
RMMM.pdf make it easy to upload and study
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Pre independence Education in Inndia.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
TR - Agricultural Crops Production NC III.pdf
VCE English Exam - Section C Student Revision Booklet
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Microbial disease of the cardiovascular and lymphatic systems
Complications of Minimal Access Surgery at WLH
RMMM.pdf make it easy to upload and study
human mycosis Human fungal infections are called human mycosis..pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Pre independence Education in Inndia.pdf
Final Presentation General Medicine 03-08-2024.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
2.FourierTransform-ShortQuestionswithAnswers.pdf
Basic Mud Logging Guide for educational purpose
Week 4 Term 3 Study Techniques revisited.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Supply Chain Operations Speaking Notes -ICLT Program
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

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