Skip to content
CHAPTER 06 / 33

Walkthrough: an expressive emoji robot

Try a display, a servo pose, text events, and optional AI interaction.

Six linked stages: choose, assemble, connect, program, test and revise.
One project connects the layout, named pins, controller and supported simulation models. Iterate after each test. View full size ↗

The Emoji companion template is the smaller reference robot. It includes a display, control electronics, a power system, and a simple servo-driven visual mechanism. Its supplied program alternates expressions and returns a bounded servo goal.

  1. Open the template chooser and select an Emoji companions variant. Review the wiring and design diagnostics before changing parts.
  2. Press Run and watch the expression alternate. In Code, find robot.display(...) and the returned servo value.
  3. Pause and change the expression strings. Press Run to start the revised program. Program globals restart after Pause/Run; a design or code edit also resets the simulation world.
  4. Try the sample below. It keeps drive motors stopped, changes the expression with simulation time, and moves the supported servo visual pose.
  5. Inspect power and the console. A speaker request is a text event, not generated sound. The microphone is not a live speech input in this release.
  6. Use AI models for an optional bounded action. A fresh emoji template may not supply a usable range observation for the offline driving fixture; a stop response is expected. Use the rover for the motion/AI walkthrough.
javascript
let lastExpression = "";

function step(robot) {
  const happy = Math.floor(robot.time / 2) % 2 === 0;
  const expression = happy ? "😊" : "🤖";
  robot.display(expression);
  if (expression !== lastExpression) {
    robot.log("Expression:", expression);
    robot.speak("Hello from my virtual robot.");
    lastExpression = expression;
  }
  return {
    left: 0,
    right: 0,
    expression,
    servo: Math.sin(robot.time) * 0.5
  };
}