Coding Level 1
Coding Level 1
Harry H. Cheng
UC Davis Center for Integrated Computing and STEM Education (C-STEM)
http://c-stem.ucdavis.edu
http://roboblockly.ucdavis.edu
Harry H. Cheng
UC Davis Center for Integrated Computing and STEM Education (C-STEM)
University of California-Davis
Copyright © 2015, UC Davis C-STEM Center, All rights reserved. No part of this publication may be reproduced or
distributed in any form or by any means, or stored in a database or retrieval system, without the prior written
consent of the author, including, but not limited to, in any network or other electronic storage or transmission, or
broadcast for distance learning.
Acknowledgements:
This work was supported in part by the National Science Foundation under grant numbers CNS-1132709, IIS-
1208690, IIS-1256780, and by the CaMSP Program of the California Department of Education.
Additional Contributor(s):
Kayce Mastrup
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
How to Use RoboBlockly Activities in your Classroom
What is the purpose of RoboBlockly?
In RoboBlockly, students program a robot using a user-friendly drag-and-drop method. Students will complete
basic problem solving to move a robot or multiple robots.
RoboBlockly is built to allow students to work at their own pace, but in general each problem should take
approximately 5 minutes to complete each activity. We encourage you to give students additional time if needed
or make it clear that they don’t need to finish the entire set of activities during one class session.
It is important to know that every browser functions differently. We encourage you to test RoboBlockly on the
computers you will have students using before implementation. Please test out the following: audio and video
streaming quality, default browser specific mechanisms for saving blocks and saving Ch code, etc. all so you are
better able to support your students. Make sure that pop ups have been enabled on all computers.
You may wish to provide headphones or ask students to bring headphones to allow students to independently
watch tutorial videos.
Prepare yourself
Go through the activities yourself so that you are familiar with what your students will be experiencing. The
Teacher Resource Packet contains all the activities and solutions for the pathway. Please note that the activities
build on previous activities in each pathways such that students may need to complete some or all activities prior
to the activity selected.
2) Based on your purpose, determine what additional resources your students will need for instruction. We do
not recommend using RoboBlockly to introduce a mathematical concept but to rather use it for skill building
or as a culminating performance task.
Use as skill building: We recommend that you provide your students with a worksheet that includes
important related definitions, work space, leading questions, etc. and encourage your students to refer to
their class notes which cover these topics.
Use as a culminating performance task: Carefully select which activity directly relates to the content you have
taught, making note that the previous activities may be necessary to complete to build prior knowledge.
When using RoboBlockly in class, first demonstrate to students how to navigate and use the RoboBlockly website.
There are five Video Tutorials, along with a self-guided interactive non-video tutorial which should be used to help
familiarize your students with the different functionalities of RoboBlockly. Helping students understand the
functionality of RoboBlockly and which elements can be manipulated in which manners is very important to
ensuring your students have full access to the content.
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Pre-Requisite Skills
RoboBlockly Activities
Prior to completing the Coding Level 1 activities, students should complete Robotics Level 1 and Level 2 activities.
The Coding Activities are intended to be self-guided, including video lessons – the Robotics Activities include
lessons on topics that are the foundation for both levels of coding in RoboBlockly.
Math
Number Sense
o Addition and subtraction with positive whole numbers.
o Moving backwards and forwards on a number line – concept of positive and negative whole
numbers.
Algebra:
o Solving basic equations.
Geometry:
o Coordinate plane, all problems are completed on a coordinate plane. Students need to be
comfortable understanding how to count, graph, and locate coordinates on a grid.
o Properties of basic Geometric shapes: circle, rectangle, squares and triangles.
Computer
Basic computer skills:
o Drag and drop using a mouse
o Key boarding
o Navigating a web browser
o Zoom In/Out in a browser
o Disabling or enabling pop-up windows
o Adjusting volume for videos
Extension
Using hardwired robots, Linkbot Controller, RoboSim or Robot Controller to execute programs built in RoboBlockly.
All can be downloaded from the UC Davis C-STEM Center’s webpage: http://c-stem.ucdavis.edu/downloads/
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
12. Multiple Robots: Changing the Initial Position and Moving Multiple driveDistance
Robots Simultaneously
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Table of Contents: Textbook to Activity Alignment
Learning Robot
Programming with Linkbot Activities
for the Absolute Beginner
5th Edition 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Section 5.1 Use Variables
x x
Section 5.2 The Output
Function printf() x
Learning Computer
Activities
Programming with Ch for
the Absolute Beginner 1 2 3 4 5 6 7 8 9 10 11 12 13 14
Section 2.1 Commonly Used
Data Types and Declaration of
x x
Variables
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #1 Drive Distance: Moving Forward
Objective: Students will use the driveDistance block to move the robot a specified distance.
This block drives the robot forward with the distance specified by the
first argument.
Pre-Placed Blocks
Wrong Prompt I did not get to where I wanted to go. Please try again.
Hint
This problem is equal to 5 + __ = 9.
robot.driveDistance(5, radius);
robot.driveDistance(4, radius);
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #1 Drive Distance: Moving Forward
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #2 Drive Distance: Moving Forward and Backward
Objective: Students will use the driveDistance block to move the robot a specified distance.
Math Skills: Understand that moving backwards requires a negative number. Familiary with
coordinate plane, and using to count spaces for distance.
RoboBlockly Activity:
Initial Student Prompt Drive Distance
Move the robot forward then backward using the DriveDistance block.
Pre-Placed Blocks
Problem Statement Drive me to 8 units forward. Then drive me 5 units backward. Finally drive
me another 9 units forward.
Hint
This problem is equivalent to moving to y = 8, then back to y = 3 and
ending on y = 12.
robot.driveDistance(8, radius);
robot.driveDistance(-5, radius);
robot.driveDistance(9, radius);
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #2 Drive Distance: Moving Forward and Backward
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 2.2 Connect Linkbots from a Computer – have students move a hardwired robot by
generating the Ch code using “Save Ch” on RoboBlockly.
10
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #3 Turn Left/Right
Objective: Students will drive the robot to an ordered pair in the coordinate plane using the
driveDistance and turnLeft/Right block.
Math Skills: Familiar with coordinate plane, ordered pairs and plotting points.
RoboBlockly Activity:
Initial Student Prompt Turn Left/Right
This block changes the direction of the robot by the amount of degrees
specified by the first argument.
The track width is the distance between the two wheels as shown
below.
Pre-Placed Blocks
Wrong Prompt You did not get me to (-4, 9). Please try again.
robot.driveDistance(9, radius);
robot.turnLeft(90, radius, trackwidth);
robot.driveDistance(4, radius);
11
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Possible Solution 2 in Ch #include <linkbot.h>
CLinkbotI robot;
double radius = 1.75;
double trackwidth = 3.69;
12
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #3 Turn Left/Right
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 5.6 Turn Left and Turn Right (turn block)
c) Section 2.2 Connect Linkbots from a Computer – have students move a hardwired robot by
generating the Ch code using “Save Ch” on RoboBlockly.
13
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #4 Debugging a Program: Running Step-by-Step to Find and Fix the Error
Objective: Students will apply their understanding of debugging to run the RoboBlockly code
step-by-step to determine what blocks need to be changed in order to make the robot
according to the problem statement.
Math Skills: Familiar with coordinate plane, ordered pairs and plotting points.
RoboBlockly Activity:
Video Lesson C2. Debugging a Program Step-by-Step
Pre-Placed Blocks
Problem Statement Use the Step function to help you “debug” the pre-placed blocks and
move Linkbot/Lego Mindstorm along the colored path shown on the
coordinate grid.
Wrong Prompt You have not fixed all the “bugs” in the pre-placed blocks. Remember to
run the code one line at a time using the step button.
Hint Remember to run the program step by step. The robot will turn right or
left based on the way it is facing. The initial move of the robot is up, along
the positive y axis.
14
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
robot.driveDistance(12, radius);
robot.turnRight(90, radius, trackwidth);
robot.driveDistance(2, radius);
robot.turnRight(90, radius, trackwidth);
robot.driveDistance(4, radius);
15
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #4 Debugging a Program: Running Step-by-Step to Find and Fix the Error
Problem Statement:
Use the Step function to help you “debug” the pre-
placed blocks and move Linkbot/Lego Mindstorm
along the colored path shown on the coordinate
grid.
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 5.5 Number Line for Distance. (driveDistance block)
c) Section 5.6 Turn Left and Turn Right (turn block)
Section 2.2 Connect Linkbots from a Computer – have students move a hardwired robot by generating
the Ch code using “Save Ch” on RoboBlockly.
16
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #5 Loops: Moving the Robot a Specified Distance Repeatedly
Objective: Students will move the robot backwards and forwards 10 times using a while loop by
inserting the driveDistance blocks.
Math Skills: Distance forward is a positive number, distance backwards is a negative number.
Familiar with coordinate plane.
RoboBlockly Activity:
Video Lesson C6. Repeating with a Loop
Pre-Placed Blocks
Problem Statement Add blocks within the repeat loop to move 10 units forward and 10 units
backward three times.
Wrong Prompt You did not move me forward and backward 10 units. Please try again.
Hint The blocks inserted should be the same except in opposite directions.
count = 0;
while(count < 3) {
robot.driveDistance(10, radius);
robot.driveDistance(-10, radius);
count = count + 1;
}
17
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #5 Loops: Moving the Robot a Specified Distance Repeatedly
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
c) Section 2.2 Connect Linkbots from a Computer – have students move a hardwired robot by
generating the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 6.1 The while Loop (repeat block)
18
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #6 Loops with Shapes Part I – Drawing a Square
Objective: Students will use a while loop and given distances to have the robot draw a square.
Math Skills: Knowledge of the basic features of Geometric shapes – square. Understand how to
plot and locate points in the coordinate plane.
RoboBlockly Activity:
Initial Student Prompt Loops with Shapes Part 1
A square is a shape with four equal sides and four equal angles.
Pre-Placed Blocks
Problem Statement Create a square with sides of length 7 using the coordinates (0,0),
(7,0), (7,7), and (0, 7).
count = 0;
while(count < 4) {
robot.driveDistance(7, radius);
robot.turnRight(90, radius, trackwidth);
count = count + 1;
}
19
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #5 Loops with Shapes Part I – Drawing a Square
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 5.6 Turn Left and Turn Right (turn block)
c) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
d) Section 2.2 Connect Linkbots from a Computer – have students move a hardwired robot by
generating the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 6.1 The while Loop (repeat block)
20
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #7 Loops with Shapes Part II – Drawing a Rectangle
Objective: Students will use a while loop and given distances to have the robot draw a
rectangle.
Math Skills: Knowledge of the basic features of Geometric shapes – rectangle. Understand how
to plot and locate points in the coordinate plane.
RoboBlockly Activity:
Initial Student Prompt Loops with Shapes Part 2
A rectangle is similar to a square except that all 4 sides do not have to be
equal, only opposite ones.
Pre-Placed Blocks
Problem Statement Create a rectangle of side lengths 5 and 10 using the coordinates (0,0),
(10,0), (10,5), and (0,5).
Hint The sequences of statements needs to create two sides of the rectangle.
count = 0;
while(count < 2) {
robot.driveDistance(5, radius);
robot.turnRight(90, radius, trackwidth);
robot.driveDistance(10, radius);
robot.turnRight(90, radius, trackwidth);
count = count + 1;
}
21
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #7 Loops with Shapes Part II – Drawing a Rectangle
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 5.6 Turn Left and Turn Right (turn block)
c) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
d) Section 2.2 Connect Linkbots from a Computer – have students move a hardwired robot by
generating the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 6.1 The while Loop (repeat block)
22
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #8 Assign and Use Variables to Move the Robot
Objective: Students will assign values to a variable and move the robot accordingly.
Pre-Placed Blocks
Problem Statement Set the distance variable to 16 units. Use the variable distance to drive
move the robot to the point located on the grid.
Wrong Prompt You did not drive the robot 16 units using the variable block. Please try
again.
Hint You will need to change the value for set distance and you will need to
change variable to distance.
distance = 16;
robot.driveDistance(distance, radius);
23
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #8 Assign and Use Variables to Move the Robot
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.1 Use Variables (set variable block)
b) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
Extension: Connect Linkbots from a Computer – have students move a hardwired robot by generating
the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 2.1 Commonly Use Data Types and Declaration of Variables (set variable block)
24
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #9 Outputting Values to the User
Objective: Students will assign values to a variable and move the robot accordingly.
Pre-Placed Blocks
Problem Statement Set the distance to 22. Add a driveDistance block and move the robot the
distance of the variable. Output: “distance is 22. The robot drove 22 units
along the y-axis.”
Hint To format the output you need to click on the box between the “ “ and
begin typing. By default the first part of the output will be “Variable is 22”
distance = 22;
robot.driveDistance(distance, radius);
printf("distance is %g The robot drove 22 units along the y-axis.\n", distance
);
25
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #9 Outputting Values to the User
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.1 Use Variables (set variable block)
b) Section 5.2 The Output Function printf() (print variable block)
c) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
Extension: Connect Linkbots from a Computer – have students move a hardwired robot by generating
the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 2.1 Commonly Use Data Types and Declaration of Variables (set variable block)
b) Section 2.2.1 The Output Function printf() (print variable and “” block)
26
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #10 Functions: Creating a Square
Objective: Students will use a function to create a square with given side lengths, centered at a
specified location in the coordinate plane.
Math Skills: Knowledge of the basic features of Geometric shapes – square. Understand how to
plot and locate points in the coordinate plane.
RoboBlockly Activity:
Video Lesson C15. Creating Functions
Pre-Placed Blocks
Problem Statement The createSquare function will draw a square with side lengths of 4,
centered on a specific position. Use the createSquare function to draw a
square centered at (3, 5).
Wrong Prompt I did not a square centered at (3, 5). Please try again.
Hint The createSquare function will automatically create a square with a side
length of 4 units. You need to use the driveToxy block to tell the program
the center of your square, then place the createSquare function block
after.
27
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #10 Functions: Creating a Square
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 5.6 Turn Left and Turn Right (turn block)
c) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
d) Section 10.1 Move a Linkbot-I in a Coordinate System (driveTo block)
Extension: Connect Linkbots from a Computer – have students move a hardwired robot by generating
the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 6.1 The while Loop (repeat block)
28
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #11 Functions: Creating a Rectangle
Objective: Students will use a function to create a rectangle with given side lengths, centered at
a specified location in the coordinate plane.
Math Skills: Knowledge of the basic features of Geometric shapes – rectangle. Understand how
to plot and locate points in the coordinate plane.
RoboBlockly Activity:
Initial Student Prompt Function
Pre-Placed Blocks
Problem Statement The createRectangle function will draw a rectangle with a height of 5
and a width of 10 centered on a specific ordered pair. Use the
createRectangle function to draw two rectangles one centered at (0,
0) and the other centered at (10, 10).
For a challenge add trace blocks to only have the robot draw the two
rectangles without any other marks on the grid.
Wrong Prompt I did not get two rectangles at those places. Please try again.
Hint The function creates a rectangle of length 5 and 10. Its center is
determined by the coordinates of the robot before the function is
called. You need to add in two driveTo blocks with the appropriate
coordinates for the center of your rectangles.
29
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Possible Solution in Ch #include <linkbot.h>
CLinkbotI robot;
double radius = 1.75;
double trackwidth = 3.69;
int count;
void createRectangle() {
robot.traceOff();
robot.driveDistance(5, radius);
robot.turnRight(90, radius, trackwidth);
robot.traceOn();
count = 0;
while(count < 2) {
robot.driveDistance(2.5, radius);
robot.turnRight(90, radius, trackwidth);
robot.driveDistance(10, radius);
robot.turnRight(90, radius, trackwidth);
robot.driveDistance(2.5, radius);
count = count + 1;
}
}
createRectangle();
robot.drivexyTo(10, 10, radius, trackwidth);
createRectangle();
30
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #11 Functions: Creating a Rectangle
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5th edition
a) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
b) Section 5.6 Turn Left and Turn Right (turn block)
c) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
d) Section 10.1 Move a Linkbot-I in a Coordinate System (driveTo block)
Extension: Connect Linkbots from a Computer – have students move a hardwired robot by generating
the Ch code using “Save Ch” on RoboBlockly.
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 6.1 The while Loop (repeat block)
31
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #12 Multiple Robots: Changing the Initial Position and Moving Multiple
Robots Simultaneously
Objective: Students will have two robots finish at the same location but travel a different total
distance.
RoboBlockly Activity:
Initial Student Prompt Multiple Robots
You can add additional robots using the
button.
Pre-Placed Blocks
Problem Statement Add a second robot. Robot 1 will start at (-3, -6). Robot 2 will start at
(0, 6). Have both robots drive to the finish line. Robot 1 will have red
blocks and Robot 2 will have green blocks.
Wrong Prompt Both robots did not make it to the finish line.
Hint You need to change the values of the driveDistance blocks for each
robot so they reach the finish line.
robot1.setSpeed(3, radius1);
robot2.setSpeed(5, radius2);
robot1.driveDistanceNB(10, radius1);
robot2.driveDistance(18, radius2);
robot1.moveWait();
32
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #12 Multiple Robots: Changing the Initial Position and Moving Multiple
Robots Simultaneously
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5th edition
e) Section 5.4 Move a Distance for a Two-Wheel Robot. (driveDistance block)
f) Section 5.6 Turn Left and Turn Right (turn block)
g) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
h) Section 10.1 Move a Linkbot-I in a Coordinate System (driveTo block)
i) Section 12.1 Control Multiple Linkbots Using the Robot Control Panel (hardwired robots)
j) Section 12.2 Control Multiple Linkbots Using a Program (hardwired robots)
k) Section 12.5 Move Multiple Linkbots with Specified Distances or Joint Angles
Extension: Connect Linkbots from a Computer – have students move a hardwired robot by generating
the Ch code using “Save Ch” on RoboBlockly.
33
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #13 Multiple Robots: The Chase around a Circle
Objective: Students will program the robots to chase around a circle. Using NB blocks.
RoboBlockly Activity:
Initial Student Prompt Multiple Robots: The Chase
Using a while loop to have robots chase each other.
Pre-Placed Blocks
Problem Statement Two robots have been placed on the coordinate grid. Robot 1 is placed
facing forwards at (0, 0) and Robot 2 is facing downwards at (14, 0).
Robot 1 will have red blocks and Robot 2 has green blocks. You will need
to insert three additional blocks for Robot 2 to make the two robots
chase each other around a circular path. The Non-Blocking blocks for
Robot 1 have already been placed. Make sure to add your three
additional blocks for Robot 2 to the inside of the repeat loop.
Wrong Prompt You did not have the robots chase each other around the circle. Please try
again.
Hint You will be adding the same blocks as robot 1, except they will not be NB
(non-blocking).
Possible Solution in Ch #include <linkbot.h>
CLinkbotI robot1;
double radius1 = 1.75;
CLinkbotI robot2;
double radius2 = 1.75;
double trackwidth1 = 3.69;
double trackwidth2 = 3.69;
int count;
robot1.setSpeed(5, radius1);
robot2.setSpeed(5, radius2);
count = 0;
while(count < 100) {
robot1.driveDistanceNB(0.6101, radius1);
34
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
robot2.driveDistance(0.6101, radius2);
robot1.turnRightNB(10, radius1, trackwidth1);
robot2.turnRight(10, radius2, trackwidth2);
robot1.driveDistanceNB(0.6101, radius1);
robot2.driveDistance(0.6101, radius2);
robot1.moveWait();
count = count + 1;
}
35
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #13 Multiple Robots – The Chase around a Circle
Problem Statement:
Two robots have been placed on the coordinate grid. Robot
1 is placed facing forwards at (0, 0) and Robot 2 is facing
downwards at (14, 0). Robot 1 will have red blocks and
Robot 2 has green blocks. You will need to insert three
additional blocks for Robot 2 to make the two robots chase
each other around a circular path. The Non-Blocking blocks
for Robot 1 have already been placed. Make sure to add
your three additional blocks for Robot 2 to the inside of the
repeat loop.
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 12.1 Control Multiple Linkbots Using the Robot Control Panel (hardwired robots)
b) Section 12.2 Control Multiple Linkbots Using a Program (hardwired robots)
c) Section 12.3 Blocking versus Non-Blocking Functions (NB blocks)
d) Section 12.4 Synchronize the Motion of Multiple Linkbots
e) Section 12.5 Move Multiple Linkbots with Specified Distances or Joint Angles
f) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
a) Section 6.1 The while Loop (repeat block)
36
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #14 Multiple Robots: The Chase around a Square
Objective: Students will change the initial position of Robot 2. They will then need to insert
additional blocks into the preplaced repeat loop to have both Robots drive in a square chasing
each other.
RoboBlockly Activity:
Initial Student Prompt Multiple Robots: The Chase
Using a while loop to have robots chase each other.
Pre-Placed Blocks
Problem Statement Two robots have been placed on the coordinate grid. Robot 1 is placed
facing right at (-5, -5) and Robot 2 is facing left at (5, 5). Robot 1 will have
red blocks and Robot 2 has green blocks. You will need to insert two
additional blocks for Robot 2 to make the two robots chase each other
around a square path. The Non-Blocking blocks for Robot 1 have already
been placed. Make sure to add your two additional blocks for Robot 2 to
the inside of the repeat loop.
Wrong Prompt You did not have the robots chase each other around the square. Please
try again.
Hint You will be adding the same blocks as robot 1, except they will not be NB
(non-blocking).
Possible Solution in Ch #include <linkbot.h>
CLinkbotI robot1;
double radius1 = 1.75;
CLinkbotI robot2;
double radius2 = 1.75;
double trackwidth2 = 3.69;
double trackwidth1 = 3.69;
int count;
robot1.setSpeed(4, radius1);
robot2.setSpeed(4, radius2);
count = 0;
while(count < 10) {
robot2.driveDistanceNB(6, radius2);
robot1.driveDistance(6, radius1);
robot2.turnLeftNB(90, radius2, trackwidth2);
robot1.turnLeft(90, radius1, trackwidth1);
count = count + 1;
}
37
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015
Coding Level 1 Activities with RoboBlockly
Activity #14 Multiple Robots – The Chase around a Square
C-STEM text alignment: Robot Programming with Linkbot for the Absolute Beginner, 5 th edition
a) Section 12.1 Control Multiple Linkbots Using the Robot Control Panel (hardwired robots)
b) Section 12.2 Control Multiple Linkbots Using a Program (hardwired robots)
c) Section 12.3 Blocking versus Non-Blocking Functions (NB blocks)
d) Section 12.4 Synchronize the Motion of Multiple Linkbots
e) Section 12.5 Move Multiple Linkbots with Specified Distances or Joint Angles
f) Appendix A.2 Use a while-loop for Repeated Motions (repeat block)
C-STEM text alignment: Learning Computer Programming with Ch for the Absolute Beginner
b) Section 6.1 The while Loop (repeat block)
38
Copyright © 2015, UC Davis C-STEM Center DRAFT Version 2 Released October 2015