2016-12-16 10:07:16 [显示全部楼层]
7175浏览
查看: 7175|回复: 1

[进阶] DFR0095红外发射模块遥控乐高红外接收器和马达

[复制链接]
昨晚成功用DFR0095红外发射模块给乐高红外接收器发送指令,带动乐高马达,so easy!
DFR0095三根线分别接Arduino的gnd、5v、数字口13,一块9v电池接LEGO 8884红外接收器,乐高8883马达按在红外接收器上,
LEGOPowerFunctions库文件复制到arduino安装目录下libraries\LEGOPowerFunctions子目录,运行以下测试代码:

[mw_shl_code=applescript,true]/*
example for the 8275 bulldozer

*/
#include <legopowerfunctions.h>

// IR led on port 13
LEGOPowerFunctions lego(13);

int timeout, count;

void setup()
{
}

void loop()
{
  timeout = 5; // 5 secs
  count = 0;
  while(timeout > 0)
  {
    lego.ComboPWM(PWM_REV4, PWM_FWD4, CH1); // 50% speed
    delay(100);
    if (count++ == 10)
    {
      timeout--;
      count = 0;
    }
  }
  lego.ComboPWM(PWM_FLT, PWM_FLT, CH1); // stop
  delay(1000);
  timeout = 3; // 5 secs
  count = 0;
  while(timeout > 0)
  {
    lego.ComboMode(RED_FWD, BLUE_FWD, CH1);  // turn
    delay(100);
    if (count++ == 10)
    {
      timeout--;
      count = 0;
    }
  }
}[/mw_shl_code]

若配合手柄,可以实现许多功能。




dsweiliang  初级技神

发表于 2016-12-19 17:06:31

感谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail