Basketball Drill Programming Alternatives

Slides:



Advertisements
Similar presentations
08/2012Tanya Mishra1 EASYC for VEX Cortex Llano Estacado RoboRaiders FRC Team 1817.
Advertisements

Intro Programming By Trevor Decker Team 1743 By Trevor Decker Team 1743.
Loops (Part 1) Computer Science Erwin High School Fall 2014.
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.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
Copyright © Texas Education Agency, Computer Programming For Loops.
Lecture 7. Review Homework 1 (sample solution) Project 1 will be assigned next week –Draw a picture (whatever you want) in the world by using turtles.
1 Introduction to Coding. 2 Example Codes A lot of example codes are given with Arduino IDE A code can often be based on a previous example rather than.
Programming – Touch Sensors Intro to Robotics. The Limit Switch When designing robotic arms there is always the chance the arm will move too far up or.
The for-statement. Different loop-statements in Java Java provides 3 types of loop-statements: 1. The for-statement 2. The while-statement 3. The do-while-statement.
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.
Chapter 6: User-Defined Functions I Instructor: Mohammad Mojaddam
1 karel_part5_loops Iteration (Loops) Loops repeat a set of instructions Two types of loops: –Definite loops ( for ) perform instructions explicit (known)
Karel J Robot An introduction to BlueJ and Object- Oriented Programming.
Working with arrays (we will use an array of double as example)
CPS120: Introduction to Computer Science Lecture 14 Functions.
Chapter 4 Grouping Objects. Flexible Sized Collections  When writing a program, we often need to be able to group objects into collections  It is typical.
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
Loops For, While, and Do While. Loop structure Loops need a control variable to operate correctly. This variable must be declared, initialized, updated,
Identifiers Identifiers in Java are composed of a series of letters and digits where the first character must be a letter. –Identifiers should help to.
Getting Started in RobotC // Comment task main() motor[] {} wait1Msec() ; = Header Code Compile Download Run Take out your notes.
Structured Programming (4 Credits) HNDIT Week 2 – Learning Outcomes Design an algorithmic solution for simple problem such as computation of a factorial,
COIT29222 Structured Programming 1 COIT29222-Structured Programming Lecture Week 02  Reading: Textbook(4 th Ed.), Chapter 2 Textbook (6 th Ed.), Chapters.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 6: User-Defined Functions I.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Chapter 3: User-Defined Functions I
RobotC Remote Control. Learning Objectives: Focusing on Virtual World with Physical Examples Understand Real-Time Joystick Mapping Understand how to use.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 6: User-Defined Functions I.
Comments, Conditional Statements Continued, and Loops Engineering 1D04, Teaching Session 4.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
FUNCTIONS. Midterm questions (1-10) review 1. Every line in a C program should end with a semicolon. 2. In C language lowercase letters are significant.
National Diploma Unit 4 Introduction to Software Development Data Structures – Loops and selection.
Functions in C++ Top Down Design with Functions. Top-down Design Big picture first broken down into smaller pieces.
Arrays and Loops. Learning Objectives By the end of this lecture, you should be able to: – Understand what a loop is – Appreciate the need for loops and.
Tarik Booker CS 242. What we will cover…  Functions  Function Syntax  Local Variables  Global Variables  The Scope of Variables  Making Functions.
Loop Design What goes into coding a loop. Considerations for Loop Design ● There are basically two kinds of loops: ● Those that form some accumulated.
Copyright © 2014 Pearson Addison-Wesley. All rights reserved. 4 Simple Flow of Control.
Identify the Appropriate Method for Handling Repetition
User-Written Functions
Introduction To Repetition The for loop
Robotics Programming Using Shaft Encoders
Objectives Identify the built-in data types in C++
Warm-up Program Use the same method as your first fortune cookie project and write a program that reads in a string from the user and, at random, will.
StartStruck in a Virtual World
Movement using Shaft Encoders
Using Encoders to go Straight
Programming – Touch Sensors
Getting Started in RobotC
Arrays & Functions Lesson xx
FOR LOOPS.
For Loops October 12, 2017.
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Using variables, for..loop and functions to help organize your code
LRobot Game.
More Loops.
Getting Started in RobotC
Java Programming Loops
Auto Straightening using VEX Shaft Encoders
Algorithms Take a look at the worksheet. What do we already know, and what will we have to learn in this term?
Coding Concepts (Basics)
For Loops.
Robotics Programming Using Shaft Encoders
Robotics Programming Using Shaft Encoders
Java Programming Loops
Robotics Programming Using Shaft Encoders
CPS125.
Is there an alternative to copy-paste for repeating code?
Programming Fundamental
Presentation transcript:

Basketball Drill Programming Alternatives Using the Basketball Drills Activity to introduce: Variables For loop Functions

Looking at Potential Solutions to Basketball Drills Pseudo Code Go forward long enough to cross the first line Come back Go forward long enough to cross the second line Go forward lone enough to cross the third line With enough guessing and checking, you can get the correct values for the wait1Msec()

Using a Variable to help with changes If only there was a tool in RobotC that would let the code repeat.

For loop in RobotC When to use it Syntax When you want to repeat something a set number of times Syntax for(int line = 1; line<=3; line++) { //Code repeated } If the line variable is less than or equal to 3 when it reaches this, it will do the loop another time. After completing the loop, it will add 1 to the variable line. Declares an integer variable called line and gives it an initial value of 1 In this example it will repeat the code inside the {} three times. Once when line = 1 Once when line = 2 And Once when line = 3

No loop vs. for loop

Since line = 1 the first time through this loop line Since line = 1 the first time through this loop line*timeToLine is the same as 1*2400 = 2400 the first time through this loop. Then 2*2400 = 4800 the second time and 3*2400 = 7200 the third time. RobotC does the math inside the () before executing the wait1Msec() command For loop example

Using Functions to make the main body easier to read Define the Functions above the main body. Main Body

Function Details //+++++ moveForward The function ‘Header’ void – It will not return a value moveForward – The name of this function. You get to pick the name of you function as long as: -Starts with a letter -No spaces or punctuation -Not a reserved Word And it should describe what it is doing. //+++++ moveForward Comments added to make the program easier to read. You can add details, … Function Details int timeToMove int – Sets an integer variable timeToMove – An integer variable that will store the value sent to the function in the call statement. The code for the function goes between {}. When the function is finished the program will return to the line after the call statement.

Dry Run: Reading the Program timeToMove timeToMove line Main Body

Online Time: Movement Challenges Basketball Drills Sentry Simulation 1 Sumo Bot Labyrinth Challenge When you complete the activities, incorporate variables, loops, and functions