Skip to content

Defining Hardware

johnmeshulam edited this page Nov 10, 2019 · 5 revisions

Syntax

Hardware is defined inside the init() method of the HardwareCreator class.

To define new motors: use new <MotorType>(String name, char port); Example: new LargeMotor("myMotor", 'A');

If you motor is inverted, add true to the end of the constructor: new LargeMotor("myMotor", 'A', true)

Available motor types: LargeMotor, MediumMotor.

To define new sensors: use new <SensorType>(String name, int port); Example: new GyroSensor("myGyro", 2);

Available sensor types: GyroSensor, TouchSensor, ColorSensor, UltrasonicSensor

To define a RobotChassis, use: new RobotChassis(String leftMotorName, char leftMotorPort, String rightMotorName, char rightMotorPort, boolean isInverted);

(There are a few constructors, in case some parameters are not specified)

Example HardwareCreator File

public class HardwareCreator {
	public static void init() {
		new RobotChassis("leftMotor", 'B', "rightMotor", 'C');
		new MediumMotor("armMotor", 'A');
		
		new GyroSensor("gyro", 1);
                new TouchSensor("touch", 2);
	}
}

Clone this wiki locally