外国牛人教你一步步快速打造首台机器人
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
- 基于DSP的机器人视觉伺服系统研究(04-17)
- 基于DSP的自动避障小车(04-05)
- 基于DSP的双足机器人运动控制系统设计(06-21)
- 用于日本震后救援的机器人技术(03-03)
- 基于TMS32OLF2407A的教育机器人硬件系统设计 (08-21)
- 基于DSP的覆冰机器人控制系统设计(02-13)
