Lesson 4: Conditional Statements Programming Solutions.

Slides:



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

Chung for Robofest 05 1 Introduction to RoboLab CJ Chung Lawrence Technological University.
An Introduction to C Adam Gleitman – IAP 2014.
Sensors For Robotics Robotics Academy All Rights Reserved.
Introductory Presentation
©2006 CSUC Institute for Research in Intelligent Systems Introduction to Coding June 15, 2006.
1 ©2006 INSciTE Lab Two Task: Make the program from Lab One (Move forward 5 rotations and turn right 90 degrees) into a MyBlock.
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.
LEGO Mindstorms NXT Programming We will be using the Common Palette for our Robots This is how you download your program onto the brick Drag and drop a.
Testbed: Exercises.
Creative Inventions and Robotics Programming with Robolab By Rebekah Gendron.
BEGINNER PROGRAMMING Lesson
GIRLS Robotic Camp. Let’s Begin Meet and Greet – Camp leaders introduce themselves – Students introduce themselves.
Programming 101 The Common Palette Content provided by Connor Statham (6 th Grade Student) Formatting by Shannon Sieber.
How to make Space Invaders
Getting Started! Lego Mindstorms Program NXT 2.0.
LabVIEW Basics Review LabVIEW Robotics Fundamentals.
Robotics Overview of NXT-G Actuators in Mindstorms. Touch sensor Labwork: Right turn. Touch/bump. [Explore move versus Motor Move mini & motor mini. Motor*.]
Today’s Agenda 1.Scribbler Program Assignment 1.Project idea due next class 2.Program demonstration due Wednesday, June 3 2.Attendance & lab pair groupings.
Sound, Touch Sensor, and Motors. Wheeled Vehicles Using the Pilot class: –Constructor Pilot(float wheelDiameter, float trackWidth,Motor leftMotor, Motor.
Motors and Sound Troubleshooting Tips. © H-CCS Problem 1 Why can’t I download my program to the RCX?
Robots Week 3a Programming Lesson 2: Modifiers, Loops and Jumps Programming Solutions.
Wall Encounter By Made easy by Dwayne Abuel.
Sentry System Multiple Sensors
3 | Touch sensors Created by H. Robinson & A. Gostelow TOUCH SENSORS.
Conditions and loops Day 4 Computer Programming through Robotics CPST 410 Summer 2009.
Clap On, Clap Off Introductory Presentation. Opening Activity What is a sensor? Can you give examples? ?
Oregon Robotics Tournament and Outreach Program RCX Basics.
Programming 101 The Common Palette Content provided by Connor Statham (9 th Grade Student) Formatting by Shannon Sieber.
1 ©2006 INSciTE Common Blocks. 2 ©2006 INSciTE Common Blocks Common blocks are full featured actions Like English statements Move Wait for an action Display.
Rescue Robot Day 2 Exploring Computer Science Lesson 6-11.
Mindstorm NXT-G Introduction Towson University Robotics.
BEGINNER FLL PROGRAMMING WORKSHOP BY DROIDS ROBOTICS & EV3LESSONS.
Lesson 1: Motors and Sound Programming Solutions.
How to make a Line Follow program Using EV3 software and an NXT light sensor.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
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.
Robotics Programming Wall Follow Line tracking for a set amount of time Line tracking for a distance.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Introductory Presentation
Introductory Presentation
Introductory Presentation
By Sanjay and Arvind Seshan
Programming – Touch Sensors
Beginner Programming Lesson
BEGINNER PROGRAMMING Lesson
Module F: Presentation Understanding Robot Fundamentals
Introductory Presentation
Beginner Programming Lesson
Line Following Behavior
Beginner Programming Lesson
While Loops and If-Else Structures
EV3 Programming guide to “Following”
Lesson 3: Sensor Wait-for’s Programming Solutions
BEGINNER PROGRAMMING Lesson
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
if-else Structures Principles of Engineering
Sumo: Stay in Ring Algorithm
While Loops and If-Else Structures
An Introduction to VEX IQ Programming with Modkit
Game Controller Lesson Four.
Obstacle Detection.
While Loops and If-Else Structures
Lego MINDSTORMS EV3.
Oregon Robotics Tournament and Outreach Program
While Loops And If-Else Structures
Implementing Variables in Your Programs
Presentation transcript:

Lesson 4: Conditional Statements Programming Solutions

Exercise 1 When the program is started, play a buzz sound if the touch sensor is pressed, else play a descending sweep sound if the touch sensor is not pressed.

Exercise 1: Solution Use a touch sensor fork If the touch sensor is pressed, play sound #5 (buzz). If the touch sensor is not pressed, play sound #3 (desc. sweep). Don’t forget the fork merge!

Exercise 2 If the light sensor is over a white piece of paper, turn on only motor A. If the light sensor is over a black piece of paper, turn on only motor C. Do this forever.

Exercise 2: Solution The Jump/Land pair runs this program forever. Don’t forget to turn off the other motor in each branch! Use a light sensor fork.

Exercise 3 Start by turning on motor A in the forward direction. If the rotational sensor has made 3 rotations, turn off motor A and exit the program. Otherwise, play a beep, wait for 1 second, and continue to check the rotational sensor.

Exercise 3: Solution When using a rotational sensor fork, you must reset the sensor. Turn on the motor 48 ticks = 3 rotations If less than 3, beep, wait 1 second, jump... …and land here. If greater than 3, turn off the motor.

Exercise 4 If the light sensor is over the white paper, then if the touch sensor is pressed in, turn on motor A in the forward direction, otherwise, turn on motor A in the reverse direction. Else, if the light sensor is over the black paper, then if the touch sensor is pressed in, turn on motor C in the forward direction, otherwise, turn on motor C in the reverse direction. For all conditions, the motor should run for 4 seconds, then stop.

Exercise 4: Solution This is an example of nested conditional statements. Don’t forget to specify different sensor ports. This stop sign stops all motors. It doesn’t care which one is on. Merge the forks from the inside back out.

Lesson 4: Conditional Statements Troubleshooting Tips

Problem 4a What’s wrong with this program?

Solution 4a Remember: All forks need a fork merge.

Problem 4b This program is supposed to turn on motor A if the touch sensor is pressed, otherwise turn on motor C. What’s wrong?

Solution 4b The branches of the fork are mixed up. This is a common mistake.

Problem 4c In this program, if the light sensor reads a value above 80, it should turn on motor B. Otherwise, it should beep. Why doesn’t it work? Hint: What is the default light level value?

Solution 4c The default light level value is 55. To specify a different value, you must use a numeric constant modifier.

Problem 4d What’s missing from this program?

Solution 4d Before every rotational sensor fork, you must reset the rotational sensor. Rotational sensor reset