13. case 03 Turn at an angle#

13.1. Our Goal#

  • To make the Ring:bit Car draw a circle in the clockwise direction.

13.2. Requiered Materials#

13.3. Hardware Connect#

  • Connect the left wheel servo to P1 of the Ring:bit expansion board and the right wheel servo to P2.

../../_images/jBVHea8.png

  • Use a rubber band to fix a pencil on the base board of the Ring:bit car.

../../_images/EfYkq79.jpg

13.4. Software#

makecode

13.5. Coding#

Step 1#

  • Click on “Advanced” in the MakeCode Drawer to see more code sections.

../../_images/2qCyzQ71.png

  • Search for “ringbitcar” and click on the ring:bit car package to add it to your project. (As below picture)

../../_images/1Wq2Mov1.jpg

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.

Step 2#

  • Snap the block set left wheel at pin P1 right wheel at pin P2 into the on start block.

  • The port number is based on the actual servo connection port. ../../_images/igG5TVD1.png

Step 3#

  • Snap the set left wheel speed right wheel speed block into the on button A pressed block.

  • Set the left wheel’s speed to 10 and the right to 50.

../../_images/Mnakk7a.png

Step 4#

  • Snap the brake block into the on button B pressed block.

../../_images/4UStidJ.png

Program#

Program Link:https://makecode.microbit.org/_YejCA2AJDDVV

If you don’t want to type these code by yourself, you can directly download the whole program from the link below:

13.6. Result#

  • On button A pressed, the car draws a circle.

  • On button B pressed, stop car.

../../_images/HStJeJY.jpg

13.7. Think#

  • How can you make your car draw an eight?

13.8. Questions#

13.9. More Information#