-
Notifications
You must be signed in to change notification settings - Fork 7
Parts and Functionalities
The parts offered in GradBot are listed below. Their functions and explanations are also listed alongside them.
Functionality: The motor's main responsibility is to move the robot around the play area. It it capable of going between the speeds of -100 and 100.
Note: A positive number provides movement forward, a negative number provides movement backwards.
Code: The motor is controlled using the following functions:
left.setPower(p);
right.setPower(p);
The variable p determines the speed of the robot as well as the direction of movement.
Default: The name of each wheel may be changed as well as the outline color and the fill color. By default, the names of the wheels are "right" and "left" and each have an outline of black with a white fill color.
Tips:
Setting both wheels to the same value will provide a consistent movement pattern either forward or backward. By varying the wheel speed, the vehicle can be turned in a circular motion.
Functionality: The main functionality of the marker is to draw in the space with a chosen color. This can be used to make a picture or track the robot's movement across the arena.
Default Info: The default name for the Marker is the next created part number, so this will need to be changed to be more specific such as "Marker" or "RedMarker".
Note: For the following examples we will name our marker "Marker". You can change the marker's name by selecting the marker under the build tab and changing its name.
Code:
To begin drawing we will use the following function:
Marker.penDown();
To stop the marker from drawing, we will use the function:
Marker.penUp():
Note: By default the pen is up. It will not draw unless placed down.
Change Colors: The color of the marker can also be changed. This will add a bit of creativity to whatever you wish to draw. To do this we will use the following code:
var color = "blue";
Marker.setColor(color);
Here we set a variable named color equal to the color blue. Then we set the marker on our vehicle to the color blue. Now our robot is ready to draw blue lines!
Additional Functions: The last two functions the marker possess are for getting the current color of the marker and seeing if the marker is currently drawing.
To get the current color of the marker we use:
Marker.color
To see if the pen is currently drawing you can use:
Marker.penDrawing
The benefits of the two previous statements come when doing loops, conditional statements, etc. which will be discussed later in the code section.
Functionality: The light serves as somewhat of a beacon. It serves as a target for other robots and is a requirement in the battle arena.
Default Info: The default name for the light is part# with the number being how many parts created so far. It is recommended you change this to a more useable name such as Light.
Code: The only function available for the Light is as follows:
Light.setColor(c)
The variable c is being used to define a color. For instance, we can set c to be "blue" like when using the marker.
Description: The light sensor is designed to measure the intensity of the sensed light.
Code:
This is done by using the following command:
lightSensor.intensity
Default Info: In this example we have named our Light Sensor "lightSensor" but you may wish to rename it something else.
Description: The range sensor gives your robot the ability to know how far away it is from an object. This can be used to avoid objects or maneuver through a course.
Code:
To find the distance we will use the following command:
rangeSensor.distance
Default Info:
In our example our variable is named rangeSensor, but you may wish to rename it to something else.
a. The laser is the most offensive piece of equipment that your robot may use. The laser is used in combat scenarios.
b. To use the laser, you will use the following function:
laser.fire();
Tip: Make sure to use a delay to avoid glitches! We'll go over this more in the code section.
a. The Chassis is the body of the robot that acts as a place to position other components such as the Laser, Light, etc.
b. The default name for the Chassis is "chassis" and it has an outline color of black with a fill color of white. These may be changed to provide any valid color combination.
c. The Chassis itself does not contain any functions.