The game needs a three second start at the beginning of the game. However if you use a 3 second delay, you might find that your code takes longer to start than the 3 seconds from power on. This is because the Python core needs time to start up.
The best advice is to test your board to see what delay is needed to get close to the 3 second delay needed in the game:
import time
time.sleep(2.5) #try 2.5 seconds at the start of your program - time it!
Motors move in the wrong direction?
If your motors are moving in the wrong direction, we can change the direction in code, look at the following BBRSumoClass.py:
The follow is a simple example of a basic robot's movement:
import time
import board
import digitalio
import pwmio
import analogio
import BBRSumoClass
sumo = BBRSumoClass.BBRSumo()
#two light sensors - varable names can be anything meaningful
#i.e. - left, right, front1, front2
AC1 = analogio.AnalogIn(board.AC1)
AC2 = analogio.AnalogIn(board.AC2)
#AC ports can also be digital ports
AC3 = digitalio.DigitalInOut(board.AC3)
AC3.direction = digitalio.Direction.INPUT
AC5 = digitalio.DigitalInOut(board.AC5)
AC3.direction = digitalio.Direction.INPUT
DC4 = digitalio.DigitalInOut(board.DC4)
DC4.direction = digitalio.Direction.INPUT
DCB1 = digitalio.DigitalInOut(board.DCB1)
DCB1.direction = digitalio.Direction.INPUT
DCB2 = digitalio.DigitalInOut(board.DCB2)
DCB2.direction = digitalio.Direction.INPUT
while True:
if AC1.value > 10000 or AC2.value > 10000:
#we have hit the white line
sumo.stop()
#give the robot some time to stop
time.sleep(0.2)
#go backwards
sumo.reverse(255)
time.sleep(0.4)
#we could turn any direction here - example has left
sumo.left(255)
#stop left turn
time.sleep(0.5)
sumo.stop()
else if AC3.value == True or AC5.value == True:
#Something is in front - Charge!
sumo.forward(255)
else if DCB1.value == True:
#something to the right?
sumo.right(255)
else if DCB2.value == True:
#something to left?
sumo.left(255)
else:
#not found? what to do - spin?, forward ?
sumo.forward(255)
time.sleep(0.01)