Have you read WPILib's screensteps live?
http://wpilib.screenstepslive.com/s/...g-a-base-class
If your base class is IterativeRobot, you will write your autonomous in
public void autonomousInit() {
// called when you enter autonomous
}
public void autonomousPeriodic() {
// called every loop through your code
}
If you know how to write teleop code, it is a simple matter to transfer that to autonomous.
For command-based robot, read the guide here:
http://wpilib.screenstepslive.com/s/...onomous-period