DFR0095红外发射模块遥控乐高红外接收器和马达
2016-12-161.7万
AI 快速预览详细
本文介绍了如何使用DFR0095红外发射模块遥控乐高8884红外接收器和8883马达。通过将DFR0095的三根线分别接Arduino的gnd、5v、数字口13,并运行特定代码,可以实现对乐高马达的控制。这种组合不仅简单易上手,还可以通过配合手柄实现更多功能。适用于STEM教育和儿童科学实验。
|
昨晚成功用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] 若配合手柄,可以实现许多功能。 |



