 I am Mr. Giridhar Jain, Assistant Professor in Electronics and Telecommunication Engineering, Valchin Institute of Technology, Solapur. Now, today I am going to explain new programming of interfacing with microcontroller 8951 with switches and 7-segment display. Now, learning outcomes. Learning outcomes of this session are, at the end of this session, students will be able to write a similar language program for interfacing circuit for 8951 with switches and 7-segment display. And second outcome is students will be able to write a similar language program for interfacing of stepper motor. Contents of the session are program for interfacing of switches and 7-segment display and program for interfacing of stepper motor. So, this is the interfacing circuit for switches, LEDs, relay and buzzer. And this is the circuit for interfacing of 7-segment display. So, here common anode 7-segment displays are used, 4 displays are used as shown in figure. So, this is PNP transistor, so this is a digit driver circuit. So, these are the 4 digit driver circuits and they are driven by P0.4, 4 to 0, line number 4, 5, 6 and 7. 7 segments of all the displays are, means for example, A of 4 displays is connected together, B of all is connected together likewise. So, they are driven by BCD to 7-segment decoder 7447. This is BCD input. So, BCD input is taken from P0.0, P0.1, 2 and 3. So, port 0, lower 4 lines are used here and port 0, upper 4 line are used for digit driver as shown in figure. So, interfacing of 7-segment display, write a program to check whether interfacing circuit is working correctly. So, think on the solution of this problem that is how to check correctly the working of interfacing circuit for 7-segment display. So, circuit already I have explained to you and we have to write a program to check this hardware. Now, for checking this interfacing circuit of 7-segment display, select one display at a time and display 0 to 9 with a delay. So, in this way we can check all the that 4-7-segment display and repeat this procedure for remaining 3 displays. Now, for example, select display 1 and display 0 on it. So, what bit pattern should be outputted at port 0? So, output pattern to port 0. So, 0, 1, 1, 1 means this 0. So, this display selected. So, display 0 is selected. And here output 0 means 0, 0, 0, 0 means output 70h to the port 0. It will select display 1 and output 0 to the display 1. Similarly, let us select display 2 and output 0 to that display. So, we have to output a pattern 1, 0, 1, 1, 0, 0, 0 that is b, 0, h. Similarly, for selecting display 3 and displaying 0 on that display 3, we have to output 1, 1, 0, 1, 0, 0, 0, 0 that is d, 0 to port 0. So, this technique is being used to output the required digit, required bcd digit on the required display from display 0 to display 3. So, interfacing of 7-segment display programming dot words is 0, 0, 0, h, s jump st dot words is 0040h, jump to start as usual. Clear P 1.4, row 1 is active means we have to start executing this program. Means we have to start checking the display if switch S1 is pressed. So, jump a bit P 1.0, check if SW1 is pressed then move R7 i mean 0 ah, i mean set the counter, counter is set for 10, MOH R6 70H. So, bit pattern required to select display 1 and output 0 that is MOH R6 70H. Then MOH R6 to A, content of R6 is MOH to the accumulator and then accumulator is MOH to the port 0, MOH A to P0 means display 0 on display 1. So, this action is taken by this instruction. Now, once 0 is displayed on display 1, A call delay, delay for 1 second, increment R6, increment counter, decrement and jump if no 0, D, G and Z R7 to DN2. So, this process is repeated till after 0 1 is displayed then 2 is displayed 3 up to 9, after 9 this loop will be over and it will go to the next line of the programming. Then MOH R7 0AH means we have to select display 2 and output 0. Again MOH R6 0B0H this is that bit pattern and this is 10 initialization counter DN3 MOH R6 to A, A to P0, A call delay, increment R6, D, G and Z R7 to DN3. So, by this program display 2 is check for displaying 0 to 9, MOH R7 0AH repeat for display 3, same program is repeated for display 3. Then we have to repeat the same program for display 4. So, MOH R7 0AH MOH R6 0AH. So, this is the bit pattern to select display 4 and output 0 to that display and this program is the same which we have done earlier only the labels are changed. So, in this way so here DN6 S jump DN6 wait in a loop means after checking display number 1 to 4 and displaying 0 to 9 this program will wait in a loop. So, this is a delay routine. So, this is a software delay. So, here resistor R0 R1 and R2 are used MOH R0 immediate 0 at H delay routine for 1 second then B1 MOH R1 0 FFH B2 B3 D, J and Z R2 to the B3 then D, J and Z R1 to the B2 and D, J and Z R0 to the B1. So, this is a delay routine. So, in this way we have check 4 7 segment displays are working and whether the program is working. Now, next is write a program for interfacing of stepper motor with the facility to increment the speed if S1 is press and decrement the speed if S2 is press and stop the motor if S3 is press. Think on solution of this programming task. This is interfacing circuit for matrix keyboard LED relay and buzzer. So, we are using the switches for increment and decrement the speed and we are using the LEDs for output which can be used further with interfacing circuit to drive a stepper motor. So, this is P 2.0 1, 2 and 3. So, these port lines are used for stepper motor program. So, .org 00H S jump S T, .org 0040, move R0 immediate 77H load the starting pattern means one line of the stepper motor here one port line is made 0 77 clear P 1.4 rho 1 active. So, rho 1 is made active to sense to check whether switch S1 or S2 is press. Move R1 0 8H load delay for default speed S1 move R0 to A that is read pattern pattern is read 77. Then rotate left RLA rotate left move A to R0 that output that pattern to here store in R0 move A to R0 is save. Then orl A immediate 0 F0 H. So, mask the MSD move P 2.1 move A to P2 that is output at port 2 to activate the LEDs A call delay. So, move A to P2 output at port 2 and A call delay means first bit pattern is outputted at port 2 and then delay is called. Then jump if bit P 1.0 to DN 1 check if S0 is press. If S0 is press we have to decrement decrement R1 to increment the speed. So, DC R1 which will increment the speed then DN 1 jump if bit P 1.1 to DN 2 check if S1 is press. So, we have to decrement the speed therefore, increment R1 DN 2 jump if bit P 1.2 to DN 3 check if S2 is press move R0 immediate 0 FF H stop the motor means if S2 is press we have to stop the motor DN 3 S jump to ST 1 means weight in a loop. Then this is the delay routine. So, dot ORG 0 1 0 0 H this is the address of delay routine and this is the delay routine same similar delay routine which we have used in the earlier program. So, move R1 to A. So, R1 is incremented or decremented for variation of speed and move A to R2 and then this is standard delay routine. So, these are the references. Thank you for watching this video.