1.L9110s控制小车前进后退左右
接通VCC,GND 模块电源指示灯亮, 以下资料来源官方,但是仍需我们调制
(前进): L1A输入低电平,L1B输入高电平
R1A输入低电平,R1B输入高电平
(后退则相反):
L1A输入高电平,L1B输入低电平
R1A输入高电平,R1B输入低电平
(左转): L1A输入低电平,L1B输入低电平
R1A输入低电平,R1B输入高电平
(右转则相反):
L1A输入低电平,L1B输入高电平
R1A输入低电平,R1B输入低电平
#include "reg52.h"
#include "intrins.h"sbit RightConlA = P3^2; //右轮
sbit RightConlB = P3^3;sbit LeftConlA = P3^4; //左轮
sbit LeftConlB = 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 goForward()
{LeftConlA = 0;LeftConlB = 1;RightConlA = 0;RightConlB = 1;
}void goBack()
{LeftConlA = 1;LeftConlB = 0;RightConlA = 1;RightConlB = 0;
}void goLeft()
{LeftConlA = 0;LeftConlB = 0;RightConlA = 0;RightConlB = 1;
}void goRight()
{LeftConlA = 0;LeftConlB = 1;RightConlA = 0;RightConlB = 0;
}void main()
{while(1){goForward();Delay1000ms();Delay1000ms();goBack();Delay1000ms();Delay1000ms();goLeft();Delay1000ms();Delay1000ms();goRight();Delay1000ms();Delay1000ms();}
}