bit:bot 遥控器

帖子: 363
注册时间: 2019年 10月 21日 13:48

bit:bot 遥控器


帖子 shaoziyang » 2019年 11月 7日 23:03


On Startup
It is always nice to have a message display on startup so you know you have the correct program loaded up. E.g.

On Bluetooth Connection
Set pins to a known state and display a message so you know the connection has been successful

On Bluetooth Disconnection
When we disconnect then make sure everything is off and send a message to the user

We can capture when buttons are pressed and released. We will make the buzzer turn on when button 4 is pressed and turn off when button 4 is released.
When button 4 is pressed we do an analog write to pin 14 to make the buzzer sound.

Move Forward
We are going to code up that when button A is pressed we will move forward and when it is released the robot will stop. This is not the only way of doing it but a nice straight forward way for this tutorial.
To move forward we need to set pins 1 and 0 high while pins 12 and 8 are low. We do this when the button A is pressed and all pins are low when the button is released.

Move Backwards
Button B is going to move the robot backwards and to do this we reverse which pins are high. This means that pins 12 and 8 are high. Same as last time, to stop the robot on releasing the button we set all pins to low.

Spin Left
Button C is going to make the robot spin left. We do this by making only the right motor move forwards.

Spin Right
Finally button D is going to spin the robot right and we do this by just rotating the left motor forwards.
图片Project Settings图片