Lessons and the learning game

Build a dog ball launcher

Flywheel physics, a sonar for the ball and one for the safety zone, distance settings from a range table, and a rest timer that looks after the dog.

What the course teaches

Six lessons in three chapters, at /learn/path/build-dog-ball-launcher on /learn.

  • Throw. Two counter-rotating 80 mm flywheels throw the ball at their surface speed, rpm / 60 x pi x d: 6.9 m/s at 1650 rpm. A photointerrupter on the top wheel measures the speed, so the ball goes only once the wheels are there (about 2 s, three of the motors' 600 ms time constants). The L298N keeps about 2.5 V, so a 7.4 V pack cannot reach speed. An HC-SR04 looking into the hopper sees the ball, and the hopper has to read empty before the next one counts.
  • Safe and on target. A second HC-SR04 guards 90 cm in front (the learner widens it to 3 m): nothing launches while something is there, and spinning wheels stop the moment a dog walks in. Three settings follow the range formula, v² x sin(2a) / g: 2.2, 4.2 and 6.2 m at 30 degrees.
  • Play. A rest after five throws in a row, then a game that changes the distance every throw.

The circuit

Part Wiring
L298N ENA on 5, IN1 and IN2 on 7 and 8 (top wheel); ENB on 6, IN3 and IN4 on 9 and 10 (bottom wheel); 12 V supply
Flywheel motors 12 V, 3000 rpm rated, on OUT1 and OUT2, OUT3 and OUT4
Tach photointerrupter on the top wheel, S on pin 2
Feeder servo on pin 3
Hopper sonar TRIG A1, ECHO A2
Zone sonar TRIG 12, ECHO 11

The sketch is ballfetch, also in the Uno's Examples menu. It takes set near, set mid, set far and status. The two sonars take turns every 70 ms.

Safety

A ball at 7 m/s can hurt. The zone sonar is a guard, not a guarantee: it sees one cone, can miss a small dog under it or a soft target at an angle, and reads "nothing" if its wires come loose. Never point a launcher at people, and supervise every game.

Troubleshooting

  • "too slow, check the supply". The motors cannot reach the setting's rpm: the supply is too low for the L298N's 2.5 V drop, or the setting is too high.
  • "blocked" or "STOP". Something is within ZONE_CM of the front.
  • A ball is not thrown again. Take it out (the hopper has to read empty), then drop it in.
  • Nothing happens after five throws. The launcher is resting for REST_MS.

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