Here is a link to the presentation slides for today.
In this first exercise, you will gain experience using conditional statements (if, else if, else). To begin, build a ClicBot that has 3 joints with the base and brain at opposite ends, as pictured below.
Create a new program called "Touch Input" and build the following program. When you add the Speaker starts playing sound []
block, you'll need to record a sound. Record a sound that you think represents happiness. For example, you could record yourself saying "yay!"
Once you've built this program and connected to your ClicBot, run the program. After the program starts running, pet your ClicBot on the head and see what it does!
Now, build on your program by adding an else
block by clicking on the blue box next to the if
, as shown below, and dragging the else
underneath the if
.
Now, exit out of this view and add onto your program by putting the Screen starts playing emotion [Curious]
inside the else
.
Before you run the program, discuss the prompt below.
Now run your program. Try to touch the robot on the head. What happens? If you don't notice anything happening, try keeping your hand on the robot's head for 5-10 seconds. Once you've seen the robot display both happy and curious emotions, discuss the prompt below.
Next, you will continue adding onto your program. You will add an else if
block similarly to how you added the else
block, see the image below.
Exit out of this view and add onto your program, copying what you see in the following code snippet. We'll need to use a new block, the or
block that you can find in the "Operators" section of the menu.
Run your program. Try both touching the robot on the head and also squeezing it on both sides of the head with one hand. Once you've been able to see all three emotions (happy, angry, curious) discuss the question below.
You've now finished this first exercise. Please wait for all groups to finish. Then, we'll go over the exercise as a class together.
For this programming exercise, your goal is to have your ClicBot detect your directional gestures (left, right, up, down) and respond by moving it's head in the opposite direction:
Let's begin with some starter code. You can use the same ClicBot shape you used for Programming Exercise #1. Begin a new program called "Opposite Gesture" and construct the following program.
When you drag on the Joint [] starts rotating to []
, you'll need to select the 2nearby
joint, which will be the one that will rotate to allow the robot's head to move up and down. You can see what the joint interface selection looks like below.
What you want to pay attention to is the joint angle listed at the bottom of the screen (circled in yellow in the image above). You can move your robot and this number should change. This will tell you what angle you want to program the robot so that it looks forward, looks up, or looks down.
IMPORTANT: If your robot has a value closer to 180 (as opposed to around 0), then you'll want to change the numbers in your starter code from 30 and 0 to 210 and 180.
Now, try running your program and giving your robot a "up" gesture. Does it work as you expect?
else
block?
Now, as a group build the rest of the program so that your ClicBot can respond to the remaining gestures (down, right, left).
Here are some tips:
Joint [] starts rotating to []
block or the Screen starts rotating to position []
block.The goal of this programming exercise is to design a robot dog that responds with emotion to your touch and/or gestures. This exercise is intentionally open ended so that you can express your creativity in the types of interactions and gestures you produce.
Examples of emotional reactions you could program include:
Some recommendations we have for you as you approach this exercise include:
Touch sensor detect touch on Brain's []
blocks, the Gesture sensor detect []
blocks, and the Touch screen detect
blocks to approach this task.The goal of this exercise is to create a ClicBot robot that is controlled by the rotation of one of it's joints. If you rotate the joint quickly, the robot will move fast. If you rotate the joint slowly, the robot will move slowly. Let's get started.
First, build a ClicBot that looks like the following picture:
As mentioned before, you'll rotate one of the ClicBot's joints to guide it's forward speed. We've attached the ClicBot holder to make this joint easier to rotate. See below for an example of how to rotate this joint for this exercise.
Now that we have the robot set up, let's get more specific about it's behavior. You'll design three "modes" for the robot:
The following piece of code gives you a snippet of what you'll need for this program.
You'll want to use the if
block to detect how fast your joint is moving. You'll use the sensor block Detect rotation speed of Joint [NO.X]
to get the rotation speed of the joint. You'll need to compare it to a numeric value. Then, you'll need to specify the wheel rotations that will follow that joint rotation speed using the Wheel [NO.X + Direction] rotation, speed
block.
Some tips for this exercise:
else
condition at the end and what that could be used for.if
block and at least one else if
block."Programming Exercise #2: Opposite Gesture Robot" was designed after the programming exercise from the ClicBot Academy Conditional Clause & Gesture Sensing Robot instructional YouTube video. "Programming Exercise #4: Using a Joint as a Sensor" was designed after the programming exercise from ClicBot Academy ClicBot Academy. Joint as A Sensor & Magical Cars instructional YouTube video.