树莓派Python编程与GPIO接口使用指南
1. Python编程基础与代码风格
1.1 机器人控制代码示例
在Python中,我们可以通过以下代码控制机器人的基本动作:
my_robot.drive_forward()
my_robot.drive_backward()
my_robot.turn_left()
my_robot.turn_right()
my_robot.set_speed(255)
my_robot.set_duration(1000)
完成代码编写后,需要进行以下操作:
1. 保存文件。
2. 按下F5运行程序。
运行程序后,在Python shell窗口中会看到类似如下的输出:
>>> ======================RESTART====================
>>>
My robot is an autonomous rover called Nomad
Nomad is driving forward 100 milliseconds
Nomad is driving backward 100 milliseconds
Nomad is turning left 100 milliseconds
Nomad is turning right 100 milliseconds
the motor speed is now 255
the duration is n
超级会员免费看
订阅专栏 解锁全文
34

被折叠的 条评论
为什么被折叠?



