can anyone here please tell me how to write the full code of 89C2051 to control the speed of the motor? how to write the code for pwm? thanks.
motor forward when p3.4 and p3.5 on, p3.3 and p3.7 off.
motor reverse when p3.3 and p3.7 on, p3.4 and p3.5 off.
below is my schematic
I think you should start with just PWM and then modify program to control a motor ..
Here is an example on how to generate PWM with 2051 (8051) microcontroller: https://www.iguanalabs.com/pwm.htm