微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 外国牛人教你一步步快速打造首台机器人

外国牛人教你一步步快速打造首台机器人

时间:07-03 来源:互联网 点击:

anger:‘ this should be your combination to make the robot drive forward, these you most likely need to adjust to fit the way you have wired your robots motors

high 5 : high 6 : low 4 : low 7

return

whichway:

gosub totalhalt ’ first stop!

‘Look one way:

gosub lturn ’ look to one side

pause servo_turn ‘ wait for the servo to be finished turning

readadc 0, b1

gosub totalhalt

’Look the other way:

gosub rturn ‘ look to another side

pause servo_turn ’ wait for the servo to be finished turning

readadc 0, b2

gosub totalhalt

‘ Decide which is the better way:

if b1《b2 then

gosub body_lturn

else

gosub body_rturn

end if

return

body_lturn:

high 6 : low 5 : low 7 : high 4 ’ this should be your combination that turns the robot one way

pause turn : gosub totalhalt

return

body_rturn:

high 5 : low 6 : low 4 : high 7 ‘ this should be your combination that turns the robot the other way

pause turn : gosub totalhalt

return

rturn:

servo 0, 100 ’ look to one side

return

lturn:

servo 0, 200 ‘ look to the other side

return

totalhalt:

low 4 : low 5 : low 6 : low 7 ’ low on all 4 halts the robot!

Servo 0,150 ‘ face forward

wait 1 ’ freeze all for one second

return

通过聪明的编程和调整,你可以使机器人动起来,转动头部,做决定,作调整,穿过类似正门这样的洞,这些动作可以同时完成。如果你使机器人在滑动的时候转动头部,这看起来会非常酷。

 玩乐时刻

你可以接一个灯或者LED到端口2和地之间。同时写下程序

要打开灯,写入

High2

要关灯,写入

Low2

装上一个激光笔如何?外加一个伺服电机呢?然后你可以使机器人把激光笔到处乱晃,开关关开,指向某个地方,你可以做任何操作。

在编译器里打下“Help”,你可以得到各种各样的指导和信息。

你可以尝试一下以下操作:

把伺服电机拿出来,把黄色芯片拿出来,插入之前拔出的达林顿晶体管,在之前连接伺服电机的2端口处接一个扬声器,在输出1时附带一个LED,或者接其它东西在输出2。然后编译以下程序:

sound 1, (100, 30)

high 2

wait 1

low 2

sound 1, (105, 60)

这会制造声音,同是会打开某些器件,制造一个新声音,关掉器件。

更有趣的是,确保Sharp芯片不拔出,接扬声器到端口1,运行以下程序:

noise:

readadc 0, b0

sound 1, (b0, 2)

goto noise

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top