You are on page 1of 2

L293D_A equ P3.6 L293D_B equ P3.7 L293D_E equ P3.

5 org 0H

;L293D A - Positive of Motor ;L293D B - Negative of Motor ;L293D E - Enable pin of IC

Main: jnb P2.6,loop jmp main

loop:

acall rotate_f acall delay acall break acall delay acall rotate_b acall delay acall break

;Rotate motor forward ;Let the motor rotate ;Stop the motor ;Wait for some time ;Rotate motor backward ;Let the motor rotate ;Stop the motor

h1: sjmp h1

;Do this in loop

rotate_f: setb L293D_A clr L293D_B setb L293D_E ret ;Make Positive of motor 1 ;Make negative of motor 0 ;Enable to run the motor

;Return from routine

rotate_b:

clr L293D_A setb L293D_B setb L293D_E ret

;Make positive of motor 0 ;Make negative of motor 1 ;Enable to run the motor

;Return from routine

break: clr L293D_A clr L293D_B clr L293D_E ret ;Make Positive of motor 0 ;Make negative of motor 0 ;Disable the o/p

;Return from routine

delay:

;Some Delay mov r7,#20H

back: mov r6,# 0ffh back1: mov r5,#0ffh here: djnz r5, here djnz r6, back1 djnz r7, back ret END

You might also like