自制乐高同款机器人瓦力—Wall-E

几乎每个人都知道电影 机器总动员(如果你不知道,现在就去看吧!)和试图清理地球的黄颜色英雄。在这个项目中,我使用了我们小朋友的乐高版本,并教会了他如何避开障碍物。这是我的第一个项目,也是了解电子基础知识的一次很好的学习经历。

第 1 步 - 代码
作为一名软件开发人员,我考虑了我想让他做什么,并准备先从代码开始。

 // This program is to control the Wall-E Lego robot.
// Wall-E is driving around. When he sees an obstacle, he stops to look around and chooses another path.
// Arduino Nano has 21 pins that can be used for digitalRead and digitalWrite
// PWM pins 3, 5, 6, 9, 10, 11 can be used for analogWrite
// pins 0 and 1 can be used for TTL
// pins 2 and 3 can be used for external interrupts
// pins 10, 11, 12, 13 support SPI communication
// pin 13 can be internal LED
// pins 14 to 21 are also analog pins A0 to A7 and can be used for analogRead
#define INFRA_RED 9   // can be any pin
#define GREEN_LED 7   // can be any pin but needs resistor, maybe 220 Ohm - or the ground pin gets 1 kOhm
#

上一篇:外星人的一天 (15 分)


下一篇:第7天-[21天学Python]-错误、异常和程序调试