[Logo for The C Shore Landing Page]
The C Shore

Programming Tips

Tip One

The five basic commands you need to operate your RoboCar are:

  1. roboCar.forward()
  2. roboCar.backward()
  3. roboCar.left()
  4. roboCar.right()
  5. roboCar.stop()

If you do not put a value between the parentheses (), the motor will run at full speed. If you put in a decimal value less that one, it will run at a slower speed. For example:

roboCar.forward(0.5)

The RoboCar will go forward at half speed. (A half (1/2) in decimal is written as 0.5)

Tip Two

The time.sleep() function tells the command in the line above it how long to operate. The sleep function understands that the value within the parentheses is the time you want in seconds. That time can be a large number (time.sleep(1000)) or a very small number (time.sleep(0.2)).  You can use different time intervals to control your RoboCar’s actions.

  
    time.sleep(0.2)
  

Tip Three

Use the “Cut and Paste” shortcut to limit the amount of code you have to type into your program. Use the Cut and Paste handout sheet in your kit to help you.