0、前言
参考:普中 51 单片机开发攻略 第14章
1、硬件

ULN2003 芯片
2、软件
mian.c
c
#include <reg52.h>
#include <intrins.h>
#include "delayms.h"
typedef unsigned char u8;
typedef unsigned int u16;
sbit DC_Motor=P1^0;
void DC_Motor_Start(u8 time)
{
DC_Motor = 1; //start motor
delayms(time*1000);
DC_Motor = 0;
}
void main()
{
DC_Motor_Start(5); //电机转动5s
while(1);
}