- To make the Ring:bit car to dance in free style.
- 1 x Ring:bit Car
- Click on "Advanced" in the MakeCode Drawer to see more code sections.
- Search for “ringbitcar” and click on the ring:bit car package to add it to your project. (As below picture)
Note: If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Project file menu.
- Snap the block
set left wheel at pin P1 right wheel at pin P2
to theOn start
block. - The port number is based on the actual servo connection port.
- Snap blocks into
forever
block. - Set an varieble to
left
and an variable toright
. - Generate a random number and assinment to the
left
and theright
.
- Set the left wheel speed to the variable left abd the right wheel speed to the variable right.
- Pause for one second.
Program Link:https://makecode.microbit.org/_WrC1kWhizc6E
If you don't want to type these code by yourself, you can directly download the whole program from the link below:
<iframe style="position:absolute;top:0;left:0;width:100%;height:100%;" src="https://makecode.microbit.org/#pub:_WrC1kWhizc6E" frameborder="0" sandbox="allow-popups allow-forms allow-scripts allow-same-origin"></iframe>
- The car runs at different speed.
- How do you ensure the car moves at a slower speed constantly?