Comparison the RANGE block Day 8 Computer Programming through Robotics CPST 410 Summer 2009.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Dublin Robotics Boosters NXT-Step Programming Workshop.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Μαθαίνοντας Python [Κ4] ‘Guess the Number’
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
More switches Day 6 Computer Programming through Robotics CPST 410 Summer 2009.
Chapter 5: Loops and Files.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Chapter 4 Making Decisions
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Variables, logic and sensors Day 3 Computer Programming through Robotics CPST 410 Summer 2009.
Robotics Catchup/Review: switch, arithmetic, range, loop Bluetooth Lab: Finish parallel parking. Next: Use Bluetooth communication for calculate & send.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
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.
Introduction to the course Computer Programming through Robotics CPST 410 Summer 2009.
Encapsulation Day 11 Computer Programming through Robotics CPST 410 Summer 2009.
Microsoft Visual Basic 2008: Reloaded Fourth Edition
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
More switches, Comparison Day 7 Computer Programming through Robotics CPST 410 Summer 2009.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
1 Session 3: Flow Control & Functions iNET Academy Open Source Web Programming.
1 CS 1430: Programming in C++. 2 Literal Values Literal values of int Literal values of float
CSE 131 Computer Science 1 Module 1: (basics of Java)
CMPS 1371 Introduction to Computing for Engineers CONDITIONAL STATEMENTS.
The LOGIC and MATH blocks Day 9 Computer Programming through Robotics CPST 410 Summer 2009.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Making Decisions.
Introduction to Data & Advanced Programming Blocks ROBOTICS II Module 1 Done by: Eng Nooran Drak.
Conditions and loops Day 4 Computer Programming through Robotics CPST 410 Summer 2009.
Lego MindStorm An Introduction to Blocks. Blocks Blocks are used to give instructions to your robot. There are many types of blocks You can use the blocks.
Robotics NXT-G: variables, file Rotation sensor Lab: Use buttons to hit specific ball. Homework: Postings. Start planning mapping the room.
Chapter Making Decisions 4. Relational Operators 4.1.
Chapter 3 Control Structures. The If…Then Statement The If…Then statement is a Decision statement = that executes a set of statements when a condition.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 4 Making Decisions.
Advanced Multimedia Development (AMMD) ::: Review – past few weeks Flash ActionScript Conditional Statements Loops Variable Type Conversion Logical.
Loops and Files. 5.1 The Increment and Decrement Operators.
CSCI 1226 FALL 2015 MIDTERM #1 REVIEWS.  Types of computers:  Personal computers  Embedded systems  Servers  Hardware:  I/O devices: mice, keyboards,
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
The Basics Input / Output, and Primitive Data Types.
EGR 115 Introduction to Computing for Engineers Branching & Program Design – Part 3 Friday 03 Oct 2014 EGR 115 Introduction to Computing for Engineers.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Controlling Program Flow with Decision Structures.
Variables  A piece of memory set aside to store data  When declared, the memory is given a name  by using the name, we can access the data that sits.
Mindstorm NXT-G Introduction Towson University Robotics.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 11 So Many Paths … So Little Time.
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
Introduction to Programming Python Lab 6: Relational Operators and Boolean Variables 12 February PythonLab6 lecture slides.ppt Ping Brennan
An Introduction to Programming with C++1 The Selection Structure Tutorial 6.
1 ©2006 INSciTE Lab Three Task: Move forward for 2 feet, turn right 90º repeat to complete a square path. End up exactly where you started.
CHAPTER 4 DECISIONS & LOOPS
Introduction to Programming
Week of 12/12/16 Test Review.
INC 161 , CPE 100 Computer Programming
Control Statement Examples
Making Decisions in a Program
Introduction to Programming
Sensors and Logic Switches
Introduction to TouchDevelop
Introduction to Programming
Programming 2 Decision-Making.
Visual Basic – Decision Statements
Programming Concepts and Database
Introduction to Programming
Unit 3: Variables in Java
Introduction to Programming
Data Types and Maths Programming Guides.
Selection Control Structure
Presentation transcript:

Comparison the RANGE block Day 8 Computer Programming through Robotics CPST 410 Summer 2009

7/1/09Harry Howard, CPST 410, Tulane University2 Course organization  Course home page Course home page  (  Lab (Newcomb 442) will be open for practice with 3-4 Macs, but you can bring your own laptop and all robots.

Comparison in NXC

7/1/09Harry Howard, CPST 410, Tulane University4 Comparison and strings  Comparison operators: >, <, ==  String operators  string [declares a variable of type string]  NumtoStr [converts a number to a string]  StrCat [concatenates strings]  TextOut [displays strings]

7/1/09Harry Howard, CPST 410, Tulane University5 The challenge, again  Tribot, 1. create two random numbers between 0 and 9 (call them A and B), 2. display them on the screen, 3. and tell me if A is greater than B.

7/1/09Harry Howard, CPST 410, Tulane University6 Parts 1 and 2 int A, B; string a, b, combined; task main() { A = random(10); B = random(10); a = NumtoStr(A); b = NumtoStr(B); combined = StrCat(a, “ < “, b); TextOut(0, 0, combined); Wait(1000); }

7/1/09Harry Howard, CPST 410, Tulane University7 Part 3, literal option int A, B; string a, b, combined; task main() { A = random(10); B = random(10); a = NumtoStr(A); b = NumtoStr(B); if (A > B) combined = StrCat(a, “ > “, b); else if (B > A) combined = StrCat(a, “ < “, b); TextOut(0, 0, combined); Wait(1000); }

7/1/09Harry Howard, CPST 410, Tulane University8 Part 3, more complete option int A, B; string a, b, combined; task main() { A = random(10); B = random(10); a = NumtoStr(A); b = NumtoStr(B); if (A > B) combined = StrCat(a, “ > “, b); else if (B > A) combined = StrCat(a, “ < “, b); else combined = StrCat(a, “ = “, b); TextOut(0, 0, combined); Wait(1000); }

7/1/09Harry Howard, CPST 410, Tulane University9 Question  Could you use an NXC switch?  No, an an NXC switch only takes numbers (integers) as inputs.

Inside or out? Kelly §16

7/1/09Harry Howard, CPST 410, Tulane University11 The challenge  Tribot, 1. Create a random number between 0 and 100, and show it on the screen. 2. Tell me if it is between 40 and 60.

7/1/09Harry Howard, CPST 410, Tulane University12 DisplayRange1.rbt displays random number on line 7 displays "between 40 and 60" on line 5 - don't clear the screen!

7/1/09Harry Howard, CPST 410, Tulane University13 The RANGE block  Robots respond to statements with True or False  A is inside the range of numbers beginning with B and ending with C.  A is outside the range of numbers beginning with B and ending with C.

7/1/09Harry Howard, CPST 410, Tulane University14 Part 2  Drag a RANGE block out of the Data row and drop it at the end of the beam.  Operation = Inside  A = 40  B = 60  Where does its input come from?  From RANDOM.

7/1/09Harry Howard, CPST 410, Tulane University15 Part 2, cont.  We again want to display both the True and False responses  Drop a SWITCH block at the end of the beam and set it up.  Control = Value  Type = Logic  Uncheck Flat view (to save screen space)  Drop a DISPLAY block into each choice  = "True"  x = "False"  Drop a NXT button WAIT block at the end to keep the results on the screen

7/1/09Harry Howard, CPST 410, Tulane University16 DisplayRange2.rbt

7/1/09Harry Howard, CPST 410, Tulane University17 Range in NXC  There is no such operation as RANGE in NXC,  so you have to break it down into its components,  using the logical operators:  && [logical AND]  || [logical OR]  ! [logical negation]

7/1/09Harry Howard, CPST 410, Tulane University18 The challenge, again  Tribot, 1. Create a random number between 0 and 100, and show it on the screen. 2. Tell me if it is between 40 and 60.

7/1/09Harry Howard, CPST 410, Tulane University19 NXC version int A; string a, combined; task main() { A = random(10); a = NumtoStr(A); if (A > 40) && (A < 60) combined = StrCat(a, “ is between 40 and 60”); else combined = StrCat(a, “ is not between 40 and 60”); TextOut(0, 0, combined); Wait(1000); }

7/1/09Harry Howard, CPST 410, Tulane University20 Next time  The LOGIC block.  Math, power, files: Kelly  Bluetooth messaging: Kelly 25.  Tasks, routines, subroutines: Kelly 26.