# 案例01:行驶控制 ## 目的 --- - 用不同的方法控制天蓬智能车行驶。 ## 使用材料 --- - [天蓬智能车(淘宝购买链接)](https://item.taobao.com/item.htm?ft=t&id=627045784239) ![](./images/TPBot_tianpeng_case_01_01.png) ## 软件 --- [微软makecode](https://makecode.microbit.org/#) ## 编程 --- - 在MakeCode的代码抽屉中点击`高级`,查看更多代码选项。 ![](./images/TPBot_tianpeng_case_01_02.png) - 为了给天蓬智能车编程,我们需要添加一个扩展库。在代码抽屉底部找到`扩展`,并点击它。这时会弹出一个对话框,搜索`tpbot`,然后点击下载这个代码库。 ![](./images/TPBot_tianpeng_case_01_03.png) ##示例程序一 - 在天蓬模块中拖出一个设置左右轮速度的积木块放入`当开机时`积木块中,并将参数都设置为100。 ![](./images/TPBot_tianpeng_case_01_04.png) ### 程序 - 请参考程序连接:[https://makecode.microbit.org/_0r5C5L029L9m](https://makecode.microbit.org/_0r5C5L029L9m) - 你也可以通过以下网页直接下载程序。
--- ## 结论 --- - 天蓬智能车会一直向前行驶 ##示例程序二 - 在天蓬模块中拖出一个`向前进速度为100%持续0秒`的积木块放入`当开机时`积木块中,并将参数都设置为速度100、持续3秒。 ![](./images/TPBot_tianpeng_case_01_05.png) ### 程序 - 请参考程序连接:[https://makecode.microbit.org/_XXH3yP66oRRp](https://makecode.microbit.org/_XXH3yP66oRRp) - 你也可以通过以下网页直接下载程序。
--- ## 结论 --- - 天蓬智能车全速前进三秒后停车 ##示例程序三 - 在天蓬模块中拖出一个`向前进速度为100%`的积木块放入`当按钮A被按下时`中,然后设置暂停2000ms,然后在天蓬模块中拖出`立刻停车`放入`当按钮A被按下时`中。 ![](./images/TPBot_tianpeng_case_01_06.png) ### 程序 - 请参考程序连接:[https://makecode.microbit.org/_6i4awR07MA7E](https://makecode.microbit.org/_6i4awR07MA7E) - 你也可以通过以下网页直接下载程序。
--- ## 结论 --- - 当按钮A被按下后,天蓬智能车全速前进两秒后停车 ## 思考 --- ## 常见问题 --- ## 相关阅读 ---