Lessons and the learning game

Build an animatronic creature

A haunted guest on four servos: keyframe timelines, easing, lip sync to a DFPlayer, PIR triggers with a rest, and idle life so it never freezes.

What the course teaches

Six lessons in three chapters, at /learn/path/build-animatronic-creature on /learn. It starts where Servos, solenoids and actuators stops: that course moves one servo with an easing curve and builds a face from a table of moods. This one runs a whole head from timelines.

  • Choreography. A clip is a list of keyframes, each a time, a servo, an angle and an easing. The player works out every servo from one clock, so all four move at once. The learner reads the pose at any moment with at look 150, sees smoothstep put the pan at 99 degrees where linear puts it at 105, adds anticipation (a wind-up the other way), finds follow-through in the numbers, and snaps a laugh with steps.
  • Sound and triggers. The talk clip waits for the DFPlayer's BUSY pin before its clock starts, so the jaw stays on the syllables. A PIR's rising edge starts the show (look, talk, laugh), and a rest ignores the PIR so the scare does not loop.
  • Alive. Random blinks and a breathing sine run between shows. The project adds a stare clip of the learner's own, puts it in the show, and fixes the guest that never restarts for a visitor who keeps moving.

The circuit

Part Wiring
PCA9685 SDA on A4, SCL on A5, VCC from the Uno, V+ from a 5 V servo supply
Servos pan on channel 0, tilt on 1, jaw on 2, lids on 3
DFPlayer Mini TX to pin 10, RX from pin 11, BUSY to pin 3, a speaker on SPK_1 and SPK_2; the card holds three 3 s tracks
PIR OUT to pin 2

The sketch is animguest, also in the Uno's Examples menu. It takes play look, play talk, play laugh, keys look, at look 150, trigger, idle on and idle off in the Serial Monitor.

Troubleshooting

  • The show does not start. The PIR has to go from low to high. If it is already high from earlier movement, wait for it to drop.
  • Motion is ignored. The guest is resting after a show for COOLDOWN_MS.
  • The jaw runs ahead of the voice. Start the clip's clock on BUSY going low, not on the play command.
  • No DFPlayer answered. Check TX to pin 10 and RX to pin 11, crossed. The guest mimes without it.
  • A new clip does not play. Its array has to be declared above CLIPS[], and its line added to CLIPS[].

Paths and lessons explains how a course, its checkpoints and its chapter quizzes work.