# Picoborg Reverse simple code?

### Forums:

Hi i teach in a primary school and one of the projects the kids in my code club want to do is make a lego compatible kit with motors etc. Anyway as i have a diddy borg i figured using the reverse with the battborg and the pi zero w would be a great way to control it all due to only needing one battery supplyand being able to control the voltages to the motor etc. Anyway i need simple code to teach the kids eg
Motor1 forwards ()
Motor2 forwards ()
That sort of thing. Just wondered if someone coukd tell me what tbe basic commands are.
Many thanks
Tim

### Below is a very basic example

Below is a very basic example of controlling motors from the PicoBorg Reverse.

In the comments below forwards / backwards refers to the PicoBorg Reverse output. The motors may run the opposite way depending on the wiring.

The `maxPower` calculation is not strictly necessary, however running the motors over their intended voltage is not recommended.

```# Load the PicoBorg Reverse library
import PicoBorgRev

# Load the standard time library
import time

# Setup the PicoBorg Reverse so it is ready to use
PBR = PicoBorgRev.PicoBorgRev()
PBR.Init()

# Reset the EPO flag to enable motors
PBR.ResetEpo()

# Determine the maximum power output
# In this case 6V motors from a 10x AA rechargeable (1.2 V) pack
maxPower = 6.0 / 12.0

# Run motor 1 forwards at full power
# for 5 seconds, then stop motor 1
PBR.SetMotor1(1.0 * maxPower)
time.sleep(5.0)
PBR.SetMotor1(0)

# Run motor 2 forwards at half power
# for 5 seconds, then stop motor 2
PBR.SetMotor2(0.5 * maxPower)
time.sleep(5.0)
PBR.SetMotor2(0)

# Run motors 3 and 4 backwards at 3/4 power
# for ten seconds, then stop all motors
PBR.SetMotor3(-0.75 * maxPower)
PBR.SetMotor4(-0.75 * maxPower)
time.sleep(10.0)
PBR.MotorsOff()

# Run all motors forwards at half power
# for ten seconds, then stop all motors
PBR.SetMotors(0.5 * maxPower)
time.sleep(10.0)
PBR.MotorsOff()
```