14浏览
查看: 14|回复: 2

[项目] 【Arduino 动手做】简单的 Walker 机器人

[复制链接]
构建一个简单的步行机器人真的很容易。不要让步数欺骗您,让您相信并非如此。这个机器人基本上是由一些家居用品和一些简单的电子产品制成的,您可以在 Radioshack 轻松捡到。事实上,这个机器人完全是拉链绑在一起的,这使得构建和修改它变得非常容易。如果您在任何时候对它的构造不满意,请剪掉扎带并以不同的方式将其扎在一起。

这个机器人的“大脑”也很容易修改,因为它基于 Arduino 开发板。对其进行编程和更改代码非常简单。即使是没有编程经验的人通常也可以很快上手并开始编写自己的机器人程序。

对我来说,这个机器人主要是一个实验,看看如果我建造了一个完整的机器人,就像我建造的众多 Simple Bots 之一一样,会发生什么。有趣的是,当你给这些生物一些计算机逻辑时,这些生物中的一个会变得多么健壮。

您将需要:
(x4)橡胶刮刀
(x2) 6“ 螺丝扣
(x1) 2” x 48“ 铝尺
(x1) 圆珠笔
(x1) 4-40 x 1/4” 螺母和螺栓
(x1) Arduino Uno REV 3
(x2) 标准伺服器
(x2) 3x1 公接头引脚(可提供 40 条)
(x1) 视差 Ping 传感器
(x1) 9V 卡扣连接器
(x1)9 伏电池座
(x1) 直流电源插头
(x1) 多用途 PC 板
(x1) 绞合 22AWG 电子线
(x1) 9 伏电池
(x1) 5-1/2“ 扎带

将舵机母插座插入 PCB 上的公头引脚,确保黑色与地对齐,红色与电源对齐,白色与绿色信号线对齐。

将 PCB 的红线插入 Arduino 5V 插座。

将 PCB 的黑线插入 Arduino 接地插座。

将 Ping 传感器的绿线插入数字引脚 7 的插座。

将前舵机的绿线插入数字引脚 9 的插座。

将后舵机的绿线插入数字引脚 10 的插座。

将电池连接到 Arduino,将其固定在电池座中,就可以开始了。

【Arduino 动手做】简单的 Walker 机器人图1

【Arduino 动手做】简单的 Walker 机器人图2

【Arduino 动手做】简单的 Walker 机器人图3

【Arduino 动手做】简单的 Walker 机器人图4

【Arduino 动手做】简单的 Walker 机器人图5

【Arduino 动手做】简单的 Walker 机器人图6

【Arduino 动手做】简单的 Walker 机器人图8

【Arduino 动手做】简单的 Walker 机器人图7

09.jpg

驴友花雕  中级技神
 楼主|

发表于 7 小时前

【Arduino 动手做】简单的 Walker 机器人

项目代码

  1. /*
  2. Simple Walker Robot
  3. by Randy Sarafan
  4. This code is for controlling a simple quadruped robot and having it respond to obstacles that approach.
  5. For more information visit the project page:
  6. https://www.instructables.com/id/Simple-Walker-Robot/
  7. This code is based on both the Arduino Sweep example by BARRAGAN
  8. and the Arduino Ping example by Tome Igoe
  9. */
  10. #include <Servo.h>
  11. Servo myservo;  // create servo object to control a servo
  12.                 // a maximum of eight servo objects can be created
  13. Servo myservo1; // create a second servo object to control a servo
  14. int pos = 80;   // variable to store the servo position for rear legs
  15.                 //changing this value changes the default position of the rear legs
  16. int pos1 = 70;  // variable to store the servo position for front legs
  17.                 //changing this value changes the default position of the front legs
  18. //determines the rate at which the legs move
  19. int rate = 1000;
  20. // this constant won't change.  It's the pin number
  21. // of the sensor's output:
  22. const int pingPin = 7;
  23. void setup()
  24. {
  25.   myservo.attach(9);      // attaches the servo on pin 9 to the servo object
  26.   myservo1.attach(10);    // attaches the servo on pin 10 to the servo object
  27.   myservo.write(pos);     // tell servo to go to position in variable 'pos' - sets center axis
  28.   myservo1.write(pos1);   // tell servo to go to position in variable 'pos' - sets center axis
  29.   delay(5000);
  30. }
  31. void loop() {
  32.   
  33.   long duration, inches, cm;
  34.   // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  35.   // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
  36.   pinMode(pingPin, OUTPUT);
  37.   digitalWrite(pingPin, LOW);
  38.   delayMicroseconds(2);
  39.   digitalWrite(pingPin, HIGH);
  40.   delayMicroseconds(5);
  41.   digitalWrite(pingPin, LOW);
  42.   // The same pin is used to read the signal from the PING))): a HIGH
  43.   // pulse whose duration is the time (in microseconds) from the sending
  44.   // of the ping to the reception of its echo off of an object.
  45.   pinMode(pingPin, INPUT);
  46.   duration = pulseIn(pingPin, HIGH);
  47.   // convert the time into a distance
  48.   inches = microsecondsToInches(duration);  
  49.   //if something is closer than a foot, back away
  50.   if(inches <= 12){
  51.     backward();
  52.   }
  53.   
  54.   //if nothing is closer than a foot, go forwards
  55.   if(inches > 12){
  56.     forward();
  57.   }
  58. }
  59. //function for going forwards
  60. void forward(){
  61.   myservo.write(pos + 20);                // tell servo to go to position in variable 'pos'
  62.   myservo1.write(pos1 - 20);              // tell servo to go to position in variable 'pos'
  63.   
  64.   delay(rate);
  65.   
  66.   myservo.write(pos - 20);                // tell servo to go to position in variable 'pos'
  67.   myservo1.write(pos1 + 20);              // tell servo to go to position in variable 'pos'
  68.   delay(rate);
  69. }
  70. //function for backing away
  71. void backward(){
  72.   myservo.write(pos + 25);                // tell servo to go to position in variable 'pos'
  73.   myservo1.write(pos1 + 50);              // tell servo to go to position in variable 'pos'
  74.   
  75.   delay(rate);
  76.   
  77.   myservo.write(pos - 25);                // tell servo to go to position in variable 'pos'
  78.   myservo1.write(pos1 - 30);              // tell servo to go to position in variable 'pos'
  79.   delay(rate);
  80. }
  81. long microsecondsToInches(long microseconds)
  82. {
  83.   // According to Parallax's datasheet for the PING))), there are
  84.   // 73.746 microseconds per inch (i.e. sound travels at 1130 feet per
  85.   // second).  This gives the distance travelled by the ping, outbound
  86.   // and return, so we divide by 2 to get the distance of the obstacle.
  87.   // See: http://www.parallax.com/dl/docs/prod/acc/28015-PING-v1.3.pdf
  88.   return microseconds / 74 / 2;
  89. }
复制代码


回复

使用道具 举报

驴友花雕  中级技神
 楼主|

发表于 7 小时前

【Arduino 动手做】简单的 Walker 机器人

【Arduino 动手做】简单的 Walker 机器人
项目链接:https://www.instructables.com/Simple-Walker-Robot/
项目作者:randofo in Circuits

项目视频 :https://www.youtube.com/watch?v=dpoy7R2c1ms&t=56s
项目代码:https://content.instructables.co ... FDGYZLPGZMIUHIO.pde

【Arduino 动手做】简单的 Walker 机器人图1

【Arduino 动手做】简单的 Walker 机器人图2

回复

使用道具 举报

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

本版积分规则

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

硬件清单

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

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

mail