ROBOTC for CORTEX While Loops Part 1

Slides:



Advertisements
Similar presentations
Robofest 2005 Introduction to Programming RIS 2.0 RCX Code.
Advertisements

While Loops and If-Else Structures
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Engineering Roles We will be forming groups of 3 students
Automation and Robotics
VEX and Robot C Chris Patterson Presented by Modified by J. Andazola.
Developed in collaboration with Introduction to Programming.
Photos and Sensor Instructions
Autonomy using Encoders Intro to Robotics. Goal Our new task is to navigate a labyrinth. But this time we will NOT use motor commands in conjunction with.
RobotC For Beginners Tyler Lutz and Keaton Bonds DRSS Enterprise.
Testbed: Exercises.
ROBOTC for VEX Online Professional Development
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
Programming Design ROBOTC Software Principles of Engineering
Technical Writing for Robotic Coding!.  du/products/teaching_robotc_cort ex/fundamentals/introtoprogramm ing/thinking/videos/fundamentals.
Wall Encounter By Made easy by Dwayne Abuel.
AUTOMATION WITH ROBOTC Starting to write and troubleshoot computer code.
Photos and Sensor Instructions
ROBOTC for CORTEX.
While and If-Else Loops ROBOTC Software. While Loops While loop is a structure within ROBOTC Allows a section of code to be repeated as long as a certain.
Automated Mechanisms Help. Potentiometers Potentiometer Check –Analog Port 2 How they work –Analog sensor –Measures rotation of a shaft between 0 and.
VEX and Robot C Chris Patterson Frisco ISD CTE Center Presented by.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
ROBOTC for CORTEX Teacher Training. ROBOTC Overview Thinking about Programming.
ROBOTC for Testbed © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
Testbed Coding In this activity you will code different challenges for the Testbed. For each challenge a sample program is shown. Use what this sample.
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions?
Testbed Coding In this activity you will code different challenges for the Testbed. For each challenge a sample program is shown. Use what this sample.
Programming Design ROBOTC Software. Behavior-Based Programming A behavior is anything your robot does –Turning on a single motor or servo Three main types.
Decision Making: while loops and Boolean Logic. While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as.
Sensor Information: while loops and Boolean Logic.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Programming Design ROBOTC Software Principles Of Engineering
Introduction to Programming in RobotC
CHAPTER 4 DECISIONS & LOOPS
VEX Cortex Video Trainer using ROBOTC
ROBOTC for VEX Online Professional Development
Introduction to Programming
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Robotics Programming Using Shaft Encoders
ROBOTC for VEX Online Professional Development
ROBOTC for VEX Online Professional Development
Automation and Robotics
Programming Design ROBOTC Software Computer Integrated Manufacturing
RobotC Sensors.
Movement using Shaft Encoders
RobotC Sensors.
Automation and Robotics
While Loops and If-Else Structures
Auto Straightening using VEX Shaft Encoders
While Loops and If-Else Structures
Introduction to RobotC
Programming Design ROBOTC Software Principles Of Engineering
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
RobotC While loop When and how to use the while loop
if-else Structures Principles of Engineering
Automation with RobotC
Robotics Programming Using Shaft Encoders
Photos and Sensor Instructions
Robotics Programming Using Shaft Encoders
While Loops and If-Else Structures
Automation with RobotC
Robotics Programming Using Shaft Encoders
While Loops and If-Else Structures
Programming Design ROBOTC Software Principles of Engineering
While Loops And If-Else Structures
Presentation transcript:

ROBOTC for CORTEX While Loops Part 1

While Loops A while loop is a structure within ROBOTC which allows a section of code to be repeated as long as a certain condition remains true. There are three main parts to every while loop.

1. The word “while” Every while loop begins with the keyword “while”.

2. The Condition The condition controls how long or how many times a while loop repeats. While the condition is true, the while loop repeats; when the condition is false, the while loop ends and the robot moves on in the program. The condition is checked every time the loop repeats, before the commands between the curly braces are run.

3. Commands to be Repeated Commands placed between the curly braces will repeat while the (condition) is true when the program checks at the beginning of each pass through the loop.

Boolean Logic Decisions robots make must always based on questions which have only two possible answers: yes or no, true or false. Statements that can be only true or false are called Boolean statements, and their true-or-false value is called a truth value.

Boolean Logic

Boolean Logic

Boolean Logic

Boolean Logic

While Loop Exercises Example 1: Program the green LED to repeatedly turn on for 2 seconds, then off for 2 seconds, forever. Example 2: Expand the previous program to loop only while the limit switch is not pressed. Trainer Notes: Recommend that trainees name their finished programs by the title of the slide, including the number and whether it was a group or individual activity. This will help them refer back to the code later.

While Loop Exercises Example 3: Program the right motor to spin forward until the potentiometer value is greater than 2048. Then program it to spin in reverse until the potentiometer value is less than 2048. Repeat while the limit switch isn’t pressed. Trainer Notes: Recommend that trainees name their finished programs by the title of the slide, including the number and whether it was a group or individual activity. This will help them refer back to the code later.

Trainer Notes: Introduce the VEX Cortex Video Trainer – Designed to teach behavior based programming using ROBOTC and the VEX Cortex

Trainer Notes: This is how you can get to the VEX Cortex Video Trainer

Additional Information

CMU Resources ROBOTC.net: http://www.robotc.net/ The ROBOTC Forum: http://www.robotc.net/forums/ Post your homework and questions here! ROBOTC PLTW Page: http:// www.robotc.net/pltw VEX Cortex Video Trainer http://www.education.rec.ri.cmu.edu/products/teaching_robotc_cortex/index.html Robotics Academy http://www.education.rec.ri.cmu.edu/content/vex/index.htm Trainer Notes: It’s recommended that you visit the different pages and show trainees the materials that are there.

Homework Program 1: Program the right motor to spin forward for 3 seconds, then reverse for 3 seconds, forever. Program 2: Program the left and right motors to spin forward until the potentiometer value is greater than 2048. Then program the motors to turn off and the LED to turn on until the potentiometer value is less than 2048. Repeat while the limit switch is not pressed. Watch the “Robot Decision Making” video (should be included with this webinar.