Case 02: Make A Shape
10. Case 02: Make A Shape#
Hi, after the learn of the first lesson, I am sure you understand the programming for Ring:bit car in a quite simple way, let’s move on by making the car run along with a shape.
10.2. Hardware Connection#
Just as what we do in the first lesson, connect the left wheel servo to P1 of the Ring:bit expansion board and the right wheel servo to P2.
10.3. Software Programming#
You should prepare the programming platform ready, if not, please can refer to this essay: Preparation for programming
# Import the modules that we need import board from ringbit import * from picoed import * from time import * # Set the pins of the servos ringbit = Ringbit(board.P2, board.P1) # While true, set the [Ring:bit](https://shop.elecfreaks.com/products/elecfreaks-pico-ed-ring-bit-v2-car-kit-with-pico-ed-board?_pos=2&_sid=18032a345&_ss=r) car run along with a square-like routine while True: ringbit.set_speed(-100, -100) sleep(1.5) ringbit.set_speed(-50, 0) sleep(1.2)
Details of program:#
Import the modules that we need.
boardis the common container, and you can connect the pins you’d like to use through it;
ringbitmodule contains classes and functions for Ring:bit smart car operation;
picoedmodule contains the operation functions to button A/B and
timemodule contains the operation functions to time.
import board from ringbit import * from picoed import * from time import *
Set the pins of the servos.
ringbit = Ringbit(board.P2, board.P1)
Set the Ring:bit car run along with a square-like routine.
while True: ringbit.set_speed(-100, -100) sleep(1.5) ringbit.set_speed(-50, 0) sleep(1.2)
The car runs along with a square-like routine.
If we want the Ring:bit car to travel with a square pentagon routine, how can we program it?