Int lineIsAtLevel = 20 // Percentage of light that is used to determine presence of a line.įloat motorError = Variables Defined Next to the Functions That Use Them If false, robot will stop after each action Int sideOfLine = RIGHTSIDE // Initialize a variable to keep track of which side of the line the robot is followingīool keepGoing = false // Some functions allow for the robot to keep moving when true Int direction = STOPPED // Initial direction of the robot is set to Stopped Int powerLevelAccessory = 20 // Level of power used by the accessory motor Int powerLevelRev = 0 // Level of power used by all Reverse motor actions Int powerLevel = 0 // Level of power used by all motor actions the config function will change this value Int mDir = FORWARD // Orientation of the motors. Int BACKWARD = -1 // These are declared as variables so they can be reversed for certain robot designs Int FORWARD = 1 // General navigation used to keep track of which direction the robot is going Internal constants used to write more readable code.Ĭonst int RIGHTSIDE = 1 // Line following constants used to tell which side of line to follow Define constants and variables to be used in the functions below Most are assigned a value in their declaration. The statements below show the definitions of various constants and variables. This is also somewhat necessary since a constant or variable cannot be used by any part of the program before it has been defined (declared). The format of this structure is one where the constants and variables are declared (for the most part) at the beginning of the file. Most function libraries have a structure to help make them easier to understand by programmers. The compilter will do that at the time your program is compiled. You can simply use one line of code to tell the compiler to include the contents of the entire library into your program. Also, if these functions and variables are stored in a file separate from your program, then you do not have to include all of the code below in order to access it. Many programs can refer to and use the same function library. The purpose of keeping these functions and variables in one file is to make your programs more modular. The functions and variables in the library can then be referenced and called upon as needed in your program. Our Function Library (Updated Spring 2013)Ī function library is a set of functions, variables, constants, and algorithms that are included with the basic RobotC programs. Javascript Programming (Robot Simulator).A Non-Functioning EV3 (i.e., frozen or dead).Very basic, since that is the assignment and you need to figure some of it out on your own. There is way more to using the sensors than I will cover in this lesson, but this will give you a taste of what is possible and get you started. Sensors covered include the Gyro, Touch, Ultrasonic and Color. Week 5 is about learning to use the sensors to control the robot. Robotics Week 04 (Functions and Reusable Code)
This is necessary so that we can begin to reuse code rather that copy and paste over and over and over and over… again. Week 4 is about learning to use the motors with functions to increase the readability and functionality of your code. Robotics Week 03 (Beginning Wheel Control) Much of our competition and challenges will involve motor and sensor control.
This is the first of several presentations that will be about motor control and sensors. Now it is time to get those motors running. Robotics Week 02 (Getting Started Using the Display) The next thing we are going to do is to learn how to make a simple program and use the display on the EV3. In order to do that we will assume that the EV3 is ‘Bricked.’ Follow the steps in this presentation. The first thing to do is to get your robot ready for ROBOTC.