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 timetime.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 timeimport boardimport digitalioimport pwmioimport analogioimport BBRSumoClasssumo = BBRSumoClass.BBRSumo()#two light sensors - varable names can be anything meaningful#i.e. - left, right, front1, front2AC1 = analogio.AnalogIn(board.AC1)AC2 = analogio.AnalogIn(board.AC2)#AC ports can also be digital portsAC3 = digitalio.DigitalInOut(board.AC3)AC3.direction = digitalio.Direction.INPUTAC5 = digitalio.DigitalInOut(board.AC5)AC3.direction = digitalio.Direction.INPUTDC4 = digitalio.DigitalInOut(board.DC4)DC4.direction = digitalio.Direction.INPUTDCB1 = digitalio.DigitalInOut(board.DCB1)DCB1.direction = digitalio.Direction.INPUTDCB2 = digitalio.DigitalInOut(board.DCB2)DCB2.direction = digitalio.Direction.INPUTwhileTrue:if AC1.value >10000or 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()elseif AC3.value ==Trueor AC5.value ==True:#Something is in front - Charge! sumo.forward(255)elseif DCB1.value ==True:#something to the right? sumo.right(255)elseif DCB2.value ==True:#something to left? sumo.left(255)else:#not found? what to do - spin?, forward ? sumo.forward(255) time.sleep(0.01)