2 Behavior-Based Programming Presentation NameCourse NameUnit # – Lesson #.# – Lesson NameBehavior-Based ProgrammingA behavior is anything your robot doesExample: Turn on a single motor or servoThree main types of behaviorComplex behavior: Robot performs a complex taskExample: automate fan controlSimple behavior: Robot performs a simple taskExample: fan stops when sensor is activatedBasic behavior: Single command to a robotExample: start a motorComplex behaviors are broken down into simple behaviors, which are broken down into basic behaviors
3 Complex BehaviorsDescribe a task or overall goal that a program will accomplishA fan runs until someone needs it to stop.A safety device warning light turns on before a fan turns on.Another light indicates that a fan has stopped.This can be described as one or more complex behaviors
4 Creating Pseudocode Break down behaviors into individual actions Do not be concerned about syntax or which commands will be used with ROBOTCSimply describe them in short phrasesExampleTurn a motor on for three secondsFollow a line until it runs into a wall
5 Simple BehaviorsBreak each complex behavior down into simple behaviorsList simple behaviors line by line in the correct sequenceDescribe actions and the prompt for each action to start
6 Creating Pseudocode Example Warning light turns on before the fan starts for three secondsFan turns on and runs until a button is pressedA different light turns on for three seconds before the program stops
7 Basic BehaviorsBreak each simple behavior down further into basic behaviorsWrite in terms of the input and output relative to the device
8 Creating Pseudocode Example Program starts Light 1 (LED 1) turns on for three secondsFan (Motor 1) turns on until a button (bumper switch) is pressedLight 2 (LED 2) turns on for 3 secondsProgram ends
9 Identify Inputs and Outputs Identify the ports by which each input and output will be connected to the CortexBe conscious which sensors are analog and which are digitalLabel a planning diagram
10 PLTW ROBOTC Program Template Presentation NameCourse NameUnit # – Lesson #.# – Lesson NamePLTW ROBOTC Program TemplateOpen Sample Program PLTWtemplateEnter an initial task description of the overall program goal in terms of complex behaviorsEnter pseudocode in terms of basic behaviors in the pseudocode section of the PLTW ROBOTC program templateSelect File, Open Sample Program. Navigate to the PLTW folder. Select the PLTWtemplate file, then select Open.
12 Program DesignEnter label for inputs and outputs in the Motors and Sensors Setup window and change drop down to identifyUse the Program Debugger to confirm that all inputs and outputs are working as expected
13 Motor 2 for 5 Seconds Presentation Name Course Name Unit # – Lesson #.# – Lesson NameMotor 2 for 5 SecondsThis example is best demonstrated using the test bed.
14 Motor 2 for 5 SecondsAll commands belonging to task main must be in between these curly braces.
23 ROBOTC Natural Language Language developed especially for PLTWLines of code for common robot behaviors are consolidated into single commandsforward();lineTrackforTime();stop();untilBump();
24 ROBOTC Natural Language Natural Language is a ROBOTC Platform Type
25 Presentation NameCourse NameUnit # – Lesson #.# – Lesson NameROBOT MotionCommands that cause the entire robot to perform a behavior
26 Movement Commands that allow control of individual motors or servos Presentation NameCourse NameUnit # – Lesson #.# – Lesson NameMovementCommands that allow control of individual motors or servos
27 Motor Reversal Reversing motor polarity Check Reverse in Motors and SetupChange speed + / - in programstartMotor(rightMotor, 63);startMotor(rightMotor, -63);
28 Presentation NameCourse NameUnit # – Lesson #.# – Lesson NameSpecialCommands that control unique VEX® Hardware: LEDs and Flashlights
29 Presentation NameCourse NameUnit # – Lesson #.# – Lesson NameUntilCommands that allow behaviors to be created for the robot to perform until an event occurs such as:Button PressEncoder Count Reached
30 Presentation NameCourse NameUnit # – Lesson #.# – Lesson NameWaitCommands that wait for an amount of time measured in seconds or milliseconds
31 Wait States Accuracy Motor Speed is affected by battery power Motors rotate faster when using a fully charged batteryMotors rotate slower when using a partially depleted batteryDevice or robot does not move consistently as the battery power drains
32 Touch Sensors Digital sensor Caution Pressed = 1 and Released = 0 When sensor is pressed or released, its value may rapidly bounce between 0 and 1 brieflyA brief wait command can reduce the bounce effect
33 ReferencesCarnegie Mellon Robotics Academy. (2011). ROBOTC. Retrieved from