Sign in:

Tutorial #1: A simple 1-line robot

Introduction:

As you learn to program Cubelets, you’ll need to learn a few key terms that describe what is happening inside your robots. If you’re new to Cubelets we recommend watching this short getting started guide:

Each Cubelet keeps track of a simple number describing its status: this number is called the Block Value. The Block Value can be any number between 0 and 255. These numbers are the “language” that Cubelets use to tell each other what to do.

Black SENSE Cubelets detect some property of their environment and turn it it a number, which we call the Block Value. The Block Value hops or flows from one Cubelet to the next, moving from SENSE blocks to ACT blocks all the time. Each Cubelet responds to Block Values differently, but ACT Cubelets take the numbers they receive and turn them into light, sound or motion.

When a Cubelet receives more than one Block Value from its neighbors, it averages the Block Values. Closer neighbors are more important to this average than further neighbors. We call the result of this averaging the “weighted average.” The weighted average is the default Cubelets method for calculating Block Values.

In this activity we are going to experiment with the concept of the “inverse” block. Inverse means the opposite. The ”inverse” block turns big Block Values into small Block Values and small Block Values into big Block Values.

Instructions:

  1. Follow the instructions below to complete the robot for this tutorial.
  2. Place your robot on the ground or table. Make sure that the Drive Cubelet wheels aren’t touching the ground. You may wish to carefully tip your robot on its side for safety.
  3. Turn on your Battery Cubelet and complete the Bluetooth Pairing process.
  4. Start by dragging the “Set actuator value to” from the “Acting” menu to canvas and place it in the “forever do” block.
  5. Drag the “inverse of” block from the “Thinking” menu to the canvas and connect it to the right edge of the “Set actuator value to” block.
  6. Drag the “weighted average” block from the “Thinking” menu to the canvas and connect it to the right edge of the “inverse of” block.
  7. The three blocks we’ve connected form a simple program. Can you guess what this program is telling your Drive Cubelet to do?
  8. It’s time to program your Drive Cubelet. Select your Drive Cubelet from the Block Map and click “Program Selected Cubelet.”
  9. Wait for Cubelets Blockly to finish updating your Cubelet.
  10. After the process is complete test your robot to see what change you can observe in your robot’s behavior.
  11. When you’re finished turn off your robot and move to the next section. Keep your robot assembled because we’ll be using the same robot in Tutorial #2: Adding parts.

Tutorial Summary:

In this tutorial we showed just how changing a simple rule in one part can affect the behavior of the entire system. By changing the rule of your Drive Cubelet so that it slows down when it gets a big Block Value and speeds up when it gets a small Block Value, you create a robot that will drive forward until it detects an object!