new_contents: # CamJam EduKit 3 - Robotics
  # Worksheet 6 – Controlling the motors with PWM
  
  import RPi.GPIO as GPIO # Import the GPIO Library
  import time # Import the Time library
  
  # Set the GPIO modes
  GPIO.setmode(GPIO.BCM)
  GPIO.setwarnings(False)
  
  # Set variables for the GPIO motor pins
  pinMotorAForwards = 10
  pinMotorABackwards = 9
  pinMotorBForwards = 8
  pinMotorBBackwards = 7
  
  # How many times to turn the pin on and off each second
  Frequency = 20
  # How long the pin stays on each cycle, as a percent (here, it's 30%)
  DutyCycle = 30
  # Settng the duty cycle to 0 means the motors will not turn
  Stop = 0
  
  # Set the GPIO Pin mode to be Output
  GPIO.setup(pinMotorAForwards, GPIO.OUT)
  GPIO.setup(pinMotorABackwards, GPIO.OUT)
  GPIO.setup(pinMotorBForwards, GPIO.OUT)
  GPIO.setup(pinMotorBBackwards, GPIO.OUT)
  
  # Set the GPIO to software PWM at 'Frequency' Hertz
  pwmMotorAForwards = GPIO.PWM(pinMotorAForwards, Frequency)
  pwmMotorABackwards = GPIO.PWM(pinMotorABackwards, Frequency)
  pwmMotorBForwards = GPIO.PWM(pinMotorBForwards, Frequency)
  pwmMotorBBackwards = GPIO.PWM(pinMotorBBackwards, Frequency)
  
  # Start the software PWM with a duty cycle of 0 (i.e. not moving)
  pwmMotorAForwards.start(Stop)
  pwmMotorABackwards.start(Stop)
  pwmMotorBForwards.start(Stop)
  pwmMotorBBackwards.start(Stop)
  
  # Turn all motors off
  def StopMotors():
      pwmMotorAForwards.ChangeDutyCycle(Stop)
      pwmMotorABackwards.ChangeDutyCycle(Stop)
      pwmMotorBForwards.ChangeDutyCycle(Stop)
      pwmMotorBBackwards.ChangeDutyCycle(Stop)
  
  # Turn both motors forwards
  def Forwards():
      pwmMotorAForwards.ChangeDutyCycle(DutyCycle)
      pwmMotorABackwards.ChangeDutyCycle(Stop)
      pwmMotorBForwards.ChangeDutyCycle(DutyCycle)
      pwmMotorBBackwards.ChangeDutyCycle(Stop)
  
  # Turn both motors backwards
  def Backwards():
      pwmMotorAForwards.ChangeDutyCycle(Stop)
      pwmMotorABackwards.ChangeDutyCycle(DutyCycle)
      pwmMotorBForwards.ChangeDutyCycle(Stop)
      pwmMotorBBackwards.ChangeDutyCycle(DutyCycle)
  
  # Turn left
  def Left():
      pwmMotorAForwards.ChangeDutyCycle(Stop)
      pwmMotorABackwards.ChangeDutyCycle(DutyCycle)
      pwmMotorBForwards.ChangeDutyCycle(DutyCycle)
      pwmMotorBBackwards.ChangeDutyCycle(Stop)
  
  # Turn Right
  def Right():
      pwmMotorAForwards.ChangeDutyCycle(DutyCycle)
      pwmMotorABackwards.ChangeDutyCycle(Stop)
      pwmMotorBForwards.ChangeDutyCycle(Stop)
      pwmMotorBBackwards.ChangeDutyCycle(DutyCycle)
  
  # Your code to control the robot goes below this line
  Forwards()
  time.sleep(1) # Pause for 1 second
  
  Left()
  time.sleep(0.5) # Pause for half a second
  
  Forwards()
  time.sleep(1)
  
  Right()
  time.sleep(0.5)
  
  Backwards()
  time.sleep(0.5)
  
  StopMotors()
  
  GPIO.cleanup()
  
subject: Create 6-pwm.py