基于STC8A8K64S4A12单片机的蓝牙遥控搬运小车

这是我在大一上学期做的一个通过蓝牙遥控 控制车前两个舵机搬运物体的小车程序。

使用L298N电机驱动

#include <STC8.H>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uint x,y,z;
sbit PA1=P1^5; //定义左舵机PWM输出的IO口
sbit PA2=P1^6; //定义右舵机PWM输出的IO口

#define SYSMCLK 27000000
/*电机驱动IO定义*/

sbit IN1 = P1^0; //为1 左电机反转	
sbit IN2 = P1^1; //为1 左电机正转	 
sbit IN3 = P1^2; //为1 右电机正转	
sbit IN4 = P1^3; //为1 右电机反转	 


unsigned  int  time=0;		
int pwm=1;
#define left_motor_en		EN1 = 1	//左电机使能
#define left_motor_stops	EN1 = 0	//左电机停止
#define right_motor_en		EN2 = 1	//右电机使能
#define right_motor_stops	EN2 = 0	//右电机停止

#define left_motor_back		IN1 = 0, IN2 = 1//左电机反转
#define left_motor_go		IN1 = 1, IN2 = 0//左电机正转
#define right_motor_back	IN3 = 1, IN4 = 0//右电机反转
#define right_motor_go		IN3 = 0, IN4 = 1//右电机正转


//int Sensor_PwmL = 20,Sensor_PwmR=22;//舵机控制 关闭位置
int Sensor_PwmL = 22,Sensor_PwmR=20;//舵机控
  • 2
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值