Arduino机器人快速上手经验分享(L298N马达驱动,摇杆模块)

Bill of Material:
直流马达(<9V, 2A) x2, 底盘 x1,9V电池 x1, 电池扣 x1, 摇杆模块 x1, L298N 马达驱动模块 x1, Arduino Uno x1, 面包板线。

.演示视频,拼装教程:

Arduino机器人快速上手经验分享

接线图
在这里插入图片描述
程式/代码:

/*  
  Demonstrates the use of Joystick control with Arduino UNO and L298N Motor Driver MOdule.
  
  Last Edited: Jan.4th.2020 by Mun Kim
*/
  
int in1 = 3; // Direction Control: Motor 1(Left Hand Side) 
int in2 = 4; // Direction Control: Motor 1(Left Hand Side) 
int enA = 5; // Power Control: Motor 1

int in3 = 7; // Direction Control: Motor 2 (Right Hand Side) 
int in4 = 8; // Direction Control: Motor 2 (Right Hand Side) 
int enB = 9; // Power Control: Motor 2 

int MotorSpeed1 = 0; // Motor 1 Speed Values - Start at zero
int MotorSpeed2 = 0; // Motor 2 Speed Values - Start at zero

int joyHorz = A0; // Joystick Input: Horizontal(X-axis)
int joyVert = A1; // Joystick Input: Vertical(Y-axis)  

// Joystick Values - Start at 512 (middle position)
int joyposVert = 512;
int joyposHorz = 512;</
  • 7
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值