SlideShare a Scribd company logo
1 of 16
INTERFACING 
KEY BOARD & DC MOTOR TO 8051
KEY BOARD INTERFACING 
• Used as an Input device 
• Connection of keys interfaced to MC
 arranged in two dimensional matrix 
>interfaced no. of port lines minimum 
 4x4 matrix:
Resistor: pull up device 
Identification: 
row scanning technique –software approach
;keyboard subroutine. This program sends the ASCII 
;code for pressed key to P0.1 
;P1.0-P1.3 connected to rows, P2.0-P2.3 to column 
MOV P2,#0FFH ;make P2 an input port 
K1: MOV P1,#0 ;ground all rows at once 
MOV A,P2 ;read all col 
;(ensure keys open) 
ANL A,00001111B ;masked unused bits 
CJNE A,#00001111B,K1 ;till all keys release 
K2: ACALL DELAY ;call 20 msec delay 
MOV A,P2 ;see if any key is pressed 
ANL A,00001111B ;mask unused bits 
CJNE A,#00001111B,OVER ;key pressed, find row 
SJMP K2 ;check till key pressed 
OVER: ACALL DELAY ;wait 20 msec debounce time 
MOV A,P2 ;check key closure 
ANL A,00001111B ;mask unused bits 
CJNE A,#00001111B,OVER1 ;key pressed, find row 
SJMP K2 ;if none, keep polling
OVER1: MOV P1, #11111110B ;ground row 0 
MOV A,P2 ;read all columns 
ANL A,#00001111B ;mask unused bits 
CJNE A,#00001111B,ROW_0 ;key row 0, find col. 
MOV P1,#11111101B ;ground row 1 
MOV A,P2 ;read all columns 
ANL A,#00001111B ;mask unused bits 
CJNE A,#00001111B,ROW_1 ;key row 1, find col. 
MOV P1,#11111011B ;ground row 2 
MOV A,P2 ;read all columns 
ANL A,#00001111B ;mask unused bits 
CJNE A,#00001111B,ROW_2 ;key row 2, find col. 
MOV P1,#11110111B ;ground row 3 
MOV A,P2 ;read all columns 
ANL A,#00001111B ;mask unused bits 
CJNE A,#00001111B,ROW_3 ;key row 3, find col. 
LJMP K2 ;if none, false input, 
;repeat
ROW_0: MOV DPTR,#KCODE0 ;set DPTR=start of row 0 
SJMP FIND ;find col. Key belongs to 
ROW_1: MOV DPTR,#KCODE1 ;set DPTR=start of row 
SJMP FIND ;find col. Key belongs to 
ROW_2: MOV DPTR,#KCODE2 ;set DPTR=start of row 2 
SJMP FIND ;find col. Key belongs to 
ROW_3: MOV DPTR,#KCODE3 ;set DPTR=start of row 3 
FIND: RRC A ;see if any CY bit low 
JNC MATCH ;if zero, get ASCII code 
INC DPTR ;point to next col. addr 
SJMP FIND ;keep searching 
MATCH: CLR A ;set A=0 (match is found) 
MOVC A,@A+DPTR ;get ASCII from table 
MOV P0,A ;display pressed key 
LJMP K1 
;ASCII LOOK-UP TABLE FOR EACH ROW 
ORG 300H 
KCODE0: DB ‘0’,’1’,’2’,’3’ ;ROW 0 
KCODE1: DB ‘4’,’5’,’6’,’7’ ;ROW 1 
KCODE2: DB ‘8’,’9’,’A’,’B’ ;ROW 2 
KCODE3: DB ‘C’,’D’,’E’,’F’ ;ROW 3 
END
KEY ISSUES IN INTERFACING SWITCHES AND 
KEY BOARD: 
 Key bounce 
 Key board scanning 
 Multiple key closure 
 Minimize hardware requirement 
 Minimize software requirement
KEY PAD ENCODER
KEY FEATURES OF KEYPAD ENCODER: 
 Automatically translates key press into a 4 Bit number 
 Built in scanning circuit 
 Overcome key bounce using a single capacitor 
 Key closure indicated by an output line 
 Last key press is stored in a latch
DC MOTOR INTERFACING 
 Unidirectional control 
 Bi directional control
Program to monitor the status of switch and monitor the 
following 
a) If SW=0 the motor moves clockwise 
b) If SW=1 the motor moves anti clock wise
Thank you

More Related Content

What's hot

COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)SUBHA SHREE
 
Algoritma pemrogmraman
Algoritma pemrogmramanAlgoritma pemrogmraman
Algoritma pemrogmramannoval riansyah
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESkarthik kadava
 
Keypad program
Keypad programKeypad program
Keypad programksaianil1
 
logic project report with coversheet
logic project report with coversheet logic project report with coversheet
logic project report with coversheet Bruno Diaz
 
STL PN-DP Slave Com Log
STL PN-DP Slave Com LogSTL PN-DP Slave Com Log
STL PN-DP Slave Com LogTony Bell
 
Logic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesLogic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesGouda Mando
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab reportJinesh Kb
 
Alc Sensor
Alc SensorAlc Sensor
Alc Sensorklee4vp
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console InterfaceDavid Young
 
Practical file
Practical filePractical file
Practical filerajeevkr35
 
Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...
Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...
Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...eSAT Publishing House
 

What's hot (18)

COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)COUNTERS(Synchronous & Asynchronous)
COUNTERS(Synchronous & Asynchronous)
 
Algoritma pemrogmraman
Algoritma pemrogmramanAlgoritma pemrogmraman
Algoritma pemrogmraman
 
VHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLESVHDL PROGRAMS FEW EXAMPLES
VHDL PROGRAMS FEW EXAMPLES
 
Keypad program
Keypad programKeypad program
Keypad program
 
Flip flops and registers
Flip flops and registersFlip flops and registers
Flip flops and registers
 
Vhdl programs
Vhdl programsVhdl programs
Vhdl programs
 
8051
80518051
8051
 
logic project report with coversheet
logic project report with coversheet logic project report with coversheet
logic project report with coversheet
 
An intro to VHDL
An intro to VHDLAn intro to VHDL
An intro to VHDL
 
STL PN-DP Slave Com Log
STL PN-DP Slave Com LogSTL PN-DP Slave Com Log
STL PN-DP Slave Com Log
 
Logic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic GatesLogic Design - Chapter 2: Logic Gates
Logic Design - Chapter 2: Logic Gates
 
VHdl lab report
VHdl lab reportVHdl lab report
VHdl lab report
 
Alc Sensor
Alc SensorAlc Sensor
Alc Sensor
 
Example MVS Console Interface
Example MVS Console InterfaceExample MVS Console Interface
Example MVS Console Interface
 
Pwm wave
Pwm wave Pwm wave
Pwm wave
 
Practical file
Practical filePractical file
Practical file
 
Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...
Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...
Design and implementation of synchronous 4 bit up counter using 180 nm cmos p...
 
Configuring Vlans
Configuring VlansConfiguring Vlans
Configuring Vlans
 

Viewers also liked

Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)REEJASHA
 
Task 5 + 6
Task 5 + 6Task 5 + 6
Task 5 + 6LD7
 
Interrupt programming
Interrupt programming Interrupt programming
Interrupt programming vijaydeepakg
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent vijaydeepakg
 
Dizee rascal analysis
Dizee rascal analysisDizee rascal analysis
Dizee rascal analysisLD7
 
Timer programming
Timer programming Timer programming
Timer programming vijaydeepakg
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)REEJASHA
 
Acls bolsillo 2010
Acls bolsillo 2010Acls bolsillo 2010
Acls bolsillo 2010nvklnd
 
Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 vijaydeepakg
 
Construction
ConstructionConstruction
ConstructionLD7
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051) vijaydeepakg
 
Deploy django apps using docker
Deploy django apps using dockerDeploy django apps using docker
Deploy django apps using dockerThomas Kremmel
 
Brand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnantBrand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnantLabCom
 
Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)Philippe Watrelot
 
Cinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur FacebookCinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur FacebookBenjamin Martin
 

Viewers also liked (20)

12 mt06ped001
12 mt06ped001 12 mt06ped001
12 mt06ped001
 
12 mt06ped008
12 mt06ped008 12 mt06ped008
12 mt06ped008
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)
 
12 mt06ped007
12 mt06ped007 12 mt06ped007
12 mt06ped007
 
Task 5 + 6
Task 5 + 6Task 5 + 6
Task 5 + 6
 
Interrupt programming
Interrupt programming Interrupt programming
Interrupt programming
 
Jp
Jp Jp
Jp
 
Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Dizee rascal analysis
Dizee rascal analysisDizee rascal analysis
Dizee rascal analysis
 
Timer programming
Timer programming Timer programming
Timer programming
 
Reeja b ed ict individual (1)
Reeja b ed ict individual (1)Reeja b ed ict individual (1)
Reeja b ed ict individual (1)
 
Acls bolsillo 2010
Acls bolsillo 2010Acls bolsillo 2010
Acls bolsillo 2010
 
Lp 30
Lp 30Lp 30
Lp 30
 
Sudhir tms 320 f 2812
Sudhir tms 320 f 2812 Sudhir tms 320 f 2812
Sudhir tms 320 f 2812
 
Construction
ConstructionConstruction
Construction
 
Applications of microcontroller(8051)
Applications of microcontroller(8051) Applications of microcontroller(8051)
Applications of microcontroller(8051)
 
Deploy django apps using docker
Deploy django apps using dockerDeploy django apps using docker
Deploy django apps using docker
 
Brand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnantBrand content et evenementiel : pari gagnant
Brand content et evenementiel : pari gagnant
 
Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)Diapo chap 09-travail-emploi-chômage (14-15)
Diapo chap 09-travail-emploi-chômage (14-15)
 
Cinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur FacebookCinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
Cinéma - Les bonnes pratiques pour promouvoir un film sur Facebook
 

Similar to Keypad and dc motor

Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2SANTIAGO PABLO ALBERTO
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACnanocdac
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdfShashiKiran664181
 
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through KeypadSteppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through KeypadAbrar Amin
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)Mashood
 
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptxWINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptxSrinivasanUma1
 
Assembly language programs 2
Assembly language programs 2Assembly language programs 2
Assembly language programs 2HarshitParkar6677
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarragaFabricio Galárraga
 
Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers finalSARITHA REDDY
 
Presentation2 1-150523155048-lva1-app6892
Presentation2 1-150523155048-lva1-app6892Presentation2 1-150523155048-lva1-app6892
Presentation2 1-150523155048-lva1-app6892Nirav rathod
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerSudhanshu Janwadkar
 

Similar to Keypad and dc motor (20)

Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2Microcontroladores: El microcontrolador 8051 con LCD 16x2
Microcontroladores: El microcontrolador 8051 con LCD 16x2
 
Keypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDACKeypad interfacing 8051 -NANOCDAC
Keypad interfacing 8051 -NANOCDAC
 
Microcontroller- An overview
Microcontroller- An overviewMicrocontroller- An overview
Microcontroller- An overview
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 
Expt 5 matrix.docx
Expt 5 matrix.docxExpt 5 matrix.docx
Expt 5 matrix.docx
 
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through KeypadSteppert Motor Interfacing With Specific Angle Entered Through Keypad
Steppert Motor Interfacing With Specific Angle Entered Through Keypad
 
Binary to bcd
Binary to bcdBinary to bcd
Binary to bcd
 
Micro c lab4(keypad)
Micro c lab4(keypad)Micro c lab4(keypad)
Micro c lab4(keypad)
 
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptxWINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
WINSEM2023-24_BECE204L_TH_VL2023240505625_2024-01-29_Reference-Material-I.pptx
 
Assembly language programs
Assembly language programsAssembly language programs
Assembly language programs
 
8086 pin function
8086 pin function8086 pin function
8086 pin function
 
Assembly language programs 2
Assembly language programs 2Assembly language programs 2
Assembly language programs 2
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarraga
 
Unit iv microcontrollers final
Unit iv microcontrollers finalUnit iv microcontrollers final
Unit iv microcontrollers final
 
Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
Taller Ensambladores
Taller EnsambladoresTaller Ensambladores
Taller Ensambladores
 
Presentation2 1-150523155048-lva1-app6892
Presentation2 1-150523155048-lva1-app6892Presentation2 1-150523155048-lva1-app6892
Presentation2 1-150523155048-lva1-app6892
 
جميع اوامر لغة الاسمبلي
جميع اوامر لغة الاسمبلي جميع اوامر لغة الاسمبلي
جميع اوامر لغة الاسمبلي
 
OptimizingARM
OptimizingARMOptimizingARM
OptimizingARM
 
Keypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 MicrocontrollerKeypad Interfacing with 8051 Microcontroller
Keypad Interfacing with 8051 Microcontroller
 

Keypad and dc motor

  • 1. INTERFACING KEY BOARD & DC MOTOR TO 8051
  • 2. KEY BOARD INTERFACING • Used as an Input device • Connection of keys interfaced to MC
  • 3.  arranged in two dimensional matrix >interfaced no. of port lines minimum  4x4 matrix:
  • 4. Resistor: pull up device Identification: row scanning technique –software approach
  • 5.
  • 6. ;keyboard subroutine. This program sends the ASCII ;code for pressed key to P0.1 ;P1.0-P1.3 connected to rows, P2.0-P2.3 to column MOV P2,#0FFH ;make P2 an input port K1: MOV P1,#0 ;ground all rows at once MOV A,P2 ;read all col ;(ensure keys open) ANL A,00001111B ;masked unused bits CJNE A,#00001111B,K1 ;till all keys release K2: ACALL DELAY ;call 20 msec delay MOV A,P2 ;see if any key is pressed ANL A,00001111B ;mask unused bits CJNE A,#00001111B,OVER ;key pressed, find row SJMP K2 ;check till key pressed OVER: ACALL DELAY ;wait 20 msec debounce time MOV A,P2 ;check key closure ANL A,00001111B ;mask unused bits CJNE A,#00001111B,OVER1 ;key pressed, find row SJMP K2 ;if none, keep polling
  • 7. OVER1: MOV P1, #11111110B ;ground row 0 MOV A,P2 ;read all columns ANL A,#00001111B ;mask unused bits CJNE A,#00001111B,ROW_0 ;key row 0, find col. MOV P1,#11111101B ;ground row 1 MOV A,P2 ;read all columns ANL A,#00001111B ;mask unused bits CJNE A,#00001111B,ROW_1 ;key row 1, find col. MOV P1,#11111011B ;ground row 2 MOV A,P2 ;read all columns ANL A,#00001111B ;mask unused bits CJNE A,#00001111B,ROW_2 ;key row 2, find col. MOV P1,#11110111B ;ground row 3 MOV A,P2 ;read all columns ANL A,#00001111B ;mask unused bits CJNE A,#00001111B,ROW_3 ;key row 3, find col. LJMP K2 ;if none, false input, ;repeat
  • 8. ROW_0: MOV DPTR,#KCODE0 ;set DPTR=start of row 0 SJMP FIND ;find col. Key belongs to ROW_1: MOV DPTR,#KCODE1 ;set DPTR=start of row SJMP FIND ;find col. Key belongs to ROW_2: MOV DPTR,#KCODE2 ;set DPTR=start of row 2 SJMP FIND ;find col. Key belongs to ROW_3: MOV DPTR,#KCODE3 ;set DPTR=start of row 3 FIND: RRC A ;see if any CY bit low JNC MATCH ;if zero, get ASCII code INC DPTR ;point to next col. addr SJMP FIND ;keep searching MATCH: CLR A ;set A=0 (match is found) MOVC A,@A+DPTR ;get ASCII from table MOV P0,A ;display pressed key LJMP K1 ;ASCII LOOK-UP TABLE FOR EACH ROW ORG 300H KCODE0: DB ‘0’,’1’,’2’,’3’ ;ROW 0 KCODE1: DB ‘4’,’5’,’6’,’7’ ;ROW 1 KCODE2: DB ‘8’,’9’,’A’,’B’ ;ROW 2 KCODE3: DB ‘C’,’D’,’E’,’F’ ;ROW 3 END
  • 9. KEY ISSUES IN INTERFACING SWITCHES AND KEY BOARD:  Key bounce  Key board scanning  Multiple key closure  Minimize hardware requirement  Minimize software requirement
  • 11. KEY FEATURES OF KEYPAD ENCODER:  Automatically translates key press into a 4 Bit number  Built in scanning circuit  Overcome key bounce using a single capacitor  Key closure indicated by an output line  Last key press is stored in a latch
  • 12. DC MOTOR INTERFACING  Unidirectional control  Bi directional control
  • 13.
  • 14.
  • 15. Program to monitor the status of switch and monitor the following a) If SW=0 the motor moves clockwise b) If SW=1 the motor moves anti clock wise