C51--小车——L9110s电机驱动模块

2023-12-13 21:47:57

电机模块开发:

L9110s:

接通VCC,GND 模块电源指示灯亮。

IA1输入高电平,IA1输入低电平,【OA1 OB1】电机正转;
IA1输入低电平,IA1输入高电平,【OA1 OB1】电机反转;
IA2输入高电平,IA2输入低电平,【OA2 OB2】电机正转;
IA2输入低电平,IA2输入高电平,【OA2 OB2】电机反转;

在这里插入图片描述

与C51连接:

在这里插入图片描述

验证正反转:

#include "reg52.h"
#include "intrins.h"


//右轮
sbit RightCon1A = P3^2;
sbit RightCon1B = P3^3;

//左轮
sbit LeftCon1A = P3^4;
sbit LeftCon1B = P3^5;

void Delay1000ms()		//@11.0592MHz
{
	unsigned char i, j, k;

	_nop_();
	i = 8;
	j = 1;
	k = 243;
	do
	{
		do
		{
			while (--k);
		} while (--j);
	} while (--i);
}


//前进
void go_Forward()
{
	RightCon1A = 0;
	RightCon1B = 1;
	
	LeftCon1A = 0;
	LeftCon1B = 1;
}

//后退
void go_Back()
{
	RightCon1A = 1;
	RightCon1B = 0;
	
	LeftCon1A = 1;
	LeftCon1B = 0;
}

//左转
void go_Left()
{
	RightCon1A = 0;
	RightCon1B = 1;
	
	LeftCon1A = 0;
	LeftCon1B = 0;
}

//右转
void go_Right()
{
	RightCon1A = 0;
	RightCon1B = 0;
	
	LeftCon1A = 0;
	LeftCon1B = 1;
}

void main()
{
	while(1){
		go_Forward();
		Delay1000ms();
		Delay1000ms();
		go_Back();
		Delay1000ms();
		Delay1000ms();
		go_Left();
		Delay1000ms();
		Delay1000ms();
		go_Right();
		Delay1000ms();
		Delay1000ms();
	}
}

文章来源:https://blog.csdn.net/weixin_48208102/article/details/134933659
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。