Variables. A variable is a space in your robot’s memory where you can store data, such as whole numbers, decimal numbers, and words. Variable names follow.

Slides:



Advertisements
Similar presentations
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
Advertisements

08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Introduction to Programming with Java, for Beginners Primitive Types Expressions Statements Variables Strings.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
ROBOTC Software Introduction. ROBOTC Software ROBOTC developed specifically for classrooms and competitions Complete programming solution for VEX Cortex.
 For Loops › for (variable set; condition; incremental or decrement){ // loop beginning › } // loop end  While loops › while (condition) { // beginning.
Chapter 2: Using Data.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Variables and Functions. Open your Encoder program Let’s begin by opening the “Labyrinth Auto Straight” code. Save this file as Labyrinth with variables.
CSC 107 – Programming For Science. Announcements  Memorization is not important, but…  … you will all still be responsible for information  Instead.
CSC 107 – Programming For Science. The Week’s Goal.
CHAPTER 4 GC 101 Data types. DATA TYPES  For all data, assign a name (identifier) and a data type  Data type tells compiler:  How much memory to allocate.
ROBOTC for VEX Online Professional Development. Warm-up Activity Review/Watch videos from VCVT –Especially the ones from the Fundamentals and Movement.
PHY-102 SAPVariables and OperatorsSlide 1 Variables and Operators In this section we will learn how about variables in Java and basic operations one can.
C++ Basics. Compilation What does compilation do? g++ hello.cpp g++ -o hello.cpp hello.
CSCI 3133 Programming with C Instructor: Bindra Shrestha University of Houston – Clear Lake.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Data Tonga Institute of Higher Education. Variables Programs need to remember values.  Example: A program that keeps track of sales needs to remember.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
 Variables can store data of different types, and different data types can do different things.  PHP supports the following data types:  String  Integer.
Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
ROBOTC for Testbed © 2011 Project Lead The Way, Inc.Automation and Robotics VEX.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
ROBOTC for VEX Online Professional Development Jesse Flot
ROBOTC for VEX Online Professional Development. Homework Questions Thoughts? Questions? Concerns? Homework Policy: All homework is due Friday, August.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
ROBOTC for VEX Online Professional Development Jesse Flot.
Bill Tucker Austin Community College COSC 1315
Introduction to Programming in RobotC
Variables and Functions
Topics Designing a Program Input, Processing, and Output
ITM 352 Data types, Variables
Variables and Functions
Variables and Functions
BASIC ELEMENTS OF A COMPUTER PROGRAM
Object Oriented Programming
Chapter 12 Variables and Operators
ROBOTC for VEX Online Professional Development
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Computer Programming Methodology Introduction to Java
Variables and Functions
Engineering Innovation Center
Chapter 3: Understanding C# Language Fundamentals
Movement using Shaft Encoders
Using Encoders to go Straight
Time Manager Class Activity Material Manager Writer leader Communicator Programmer Start a journey from the capital AbuDhabi to Alasmaa School using your.
Variables and Functions
Variables and Functions
Variables and Functions
Variables and Functions
IDENTIFIERS CSC 111.
Using variables, for..loop and functions to help organize your code
Unit 2 Programming.
Variables ICS2O.
Variables and Functions
Numbers.
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Auto Straightening using VEX Shaft Encoders
C++ Data Types Data Type
Chapter 2: Introduction to C++.
Robotics Programming Using Shaft Encoders
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Just Enough Java 17-May-19.
DATA TYPES There are four basic data types associated with variables:
Variables and Constants
COMPUTING.
Presentation transcript:

Variables

A variable is a space in your robot’s memory where you can store data, such as whole numbers, decimal numbers, and words. Variable names follow the same rules as custom motor and sensor names: –Capitalization, Spelling, Availability Usefulness –Can store data to be manipulated by your robot –Can improve the readability and expandability of your programs

Variables Data TypeDescriptionExampleCode IntegerPositive and negative whole numbers, as well as zero. -35, -1, 0, 33, 100 int Floating Point Number Numeric values with decimal points (even if the decimal part is zero) , 0.56, 3.0, float BooleanTrue or False. Useful for expressing the outcomes of comparisons. true, false bool CharacterIndividual characters, placed in single quotes. ‘L’, ‘f’, ‘8’ char StringStrings of characters, such as words and sentences placed in double quotes. “Hello World!”, “asdf” string

Creating a Variable To create a variable, you must “declare” the type of data it will hold. You must also declare a name by which it can be referenced: Variables can be set to different values throughout your program. Giving a variable its initial value is called “initializing” it.

Global Variables Select View then Preferences. Select Compiler then Code Generation. In Code Generation For Stack, select Force ‘Classic’ – All Memory Allocation as Globals.

Variables Part II

Common Variable Uses Variables are useful for keeping track of loop iterations. The following code lets the loop run 10x. Note that the side on the right of the equal sign is evaluated first, then set to the variable on the left. This is always the case.

Common Variable Uses Variables are useful for keeping track of sensor or timer values at different parts of the program.

Common Variable Uses Variables are useful for keeping track of results from complicated equations.

Global Variables Window This window displays all of the variables in your program in real-time.

Operator Shortcuts Automatically adds 1 to x x = x + 1; Automatically subtracts 1 from x x = x – 1; Automatically adds 2 to x x = x + 2; Automatically subtracts 2 from x x = x – 2;

Variables Exercise 1 Program the motors to spin forward until the touch sensor is pressed. Record the elapsed time in an “elapsedTime” integer variable. The motors should spin in reverse for one-half of the elapsed time. Watch the timer values in the ROBOTC Timers debug window. Watch the variable values in the Global Variables window.

Variables Exercise 2 Write a program that for any distance will calculate the number of encoder counts needed. Create variables to: –Store the desired distance –Store the circumference of your wheel –Store the value of PI –Store the result of your equation Watch the value of the variables in the Global Variables window.