Class Meeting 06: Advanced Blockly I


Learning Goals



Lecture Overview


Today we will continue to familiarize ourselves with using conditionals and sensory input in Blockly. We will also introduce the concept of angle arithmetic and how to use it to control multiple joints at once. We will then apply these concepts to a fun and competitive exercise where you will program your ClicBot to battle against your classmates' ClicBots.

Today's Timeline

Programming Exercise #1: Using a Joint as a Sensor


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:

Robot Exercise 4

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.

Rotating Joint

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:

You'll likely find the following code blocks helpful for this exercise:

Exercise 2 Sensor Options
Exercise 2 Actuator Options
Exercise 3 Control Options
Exercise 3 Operator Options

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:


Programming Exercise #2: Emotional Robot Dog


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:

Robot Dog

[Headstart] Programming Exercise #3: Getting a joint pair to work together.


In this first exercise, get some hands on experience with measuring joint angles and using that measurement to move other joints. To begin, build a ClicBot that has 6 joints with the base, a long arm, a gripper, and a brain, as pictured below.

ex 1 plain build

Then, create a new program that measures the angle of joint A (pictured). HINT: use the "detect servo angle" sensor in the sensors tab.


Once you're familiar with how the angle reading of joint A changes as you rotate the joint upon its axis, add additional logic to make joint B mimic the movements of joint A.

HINT 1: you can use constant offsets to account for the angle difference in which joint A and joint B start at.

HINT 2: is your logic correct but the program not doing anything? Maybe it is doing something really but just doing once, really quickly that you didn't notice. How do you get it to keep doing it?

exercise 1 build with joints labeled

This is what your finished product should do.

final gif
Discuss as a group: Once you're done, compare your program with your neighbors - are there any drastic differences? If so, what do you think contributed to this disparity?

Today's Exit Ticket


Here's a link to today's exit ticket survey. The exit ticket will ask you for: