Skip to content

Class 6 · Tournament

Your catapult finds, aims and fires by itself. Today it competes. Challengers aim it by hand; your code aims it automatically. Same catapult, same cups. Which wins?

By the end of class

Your catapult has played the tournament, and you can explain to a visitor how it finds a cup.

New parts today

Part What it's for
Second 10 kΩ pot The range knob, for hand-aimed shots

Build it

A challenger needs to set the range by hand, too. Wire a second knob, everything unplugged:

From To
Pot outer legs Logic rail + and −
Pot middle leg A2

Tool: one input, two jobs

The stop bar now has two bosses: your stopAngleFor() during an automatic shot, and the range knob the rest of the time. The trick is to decide who's in charge at each moment, and only let that one move it.

A thermostat works the same way. Normally the dial sets the temperature; while "eco mode" is on, the program does, and the dial is ignored:

#include <Arduino.h>

const int ECO_SWITCH = 2;   // on reads LOW
int target;                 // temperature we're aiming for

void setup() {
  pinMode(ECO_SWITCH, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  bool eco = (digitalRead(ECO_SWITCH) == LOW);

  if (eco) {
    target = 18;                                   // the program decides
  } else {
    target = map(analogRead(A0), 0, 1023, 15, 25); // the dial decides
  }

  Serial.println(target);
  delay(200);
}

In your catapult, the automatic shot is "eco mode": while it runs, the knobs are ignored.

Mission 1 · Manual mode

The range knob moves the stop bar across the angles from your table, from shortest to longest. The aiming knob still turns the turret. During an automatic run, both knobs are ignored.

Done when

Someone who has never used your catapult hits a cup at 1.5 m by hand, using only the two knobs and the fire button.

Mission 2 · Ten-shot test

Before the tournament, find out how good your automatic mode really is. Someone else places one cup, anywhere in range, ten times. Ten automatic runs. Record each one: hit, short, long, left, right. Fix the miss that happens most, if there's time.

Done when

Your ten results are in your build log, with your hit count.

Mission 3 · The tournament

Dr. Alvear sets the final rules. The plan:

  • Three cups, placed by the other side, between 1 m and your longest shot.
  • Hand-aimed: a challenger (another group, or Dr. Alvear) gets five shots with the knobs.
  • Automatic: your catapult gets five automatic runs at the same cups, untouched.
  • Most hits wins. A tie goes to whichever side was faster.
  • Every rule from Class 1 still applies: soft ammo, armed only when everyone's clear, a countdown before every automatic shot.

Done when

You've played, the score is in your build log, and you've told a visitor, in your own words, how the catapult finds a cup and picks its range.

Stretch goals

Only once Missions 1–3 are done:

  • LED countdown. Three LEDs that go out one by one with the beeps. Pins A3, A4 and A5 are free (each through 470 Ω).
  • Aiming laser for manual mode. Only a low-power laser module from Dr. Alvear, mounted level, and never pointed at anyone's eyes.
  • Motorized re-cock. Pulling the arm back against the rubber bands takes real force. Talk to Dr. Alvear before you start; this is a project of its own.
  • Smarter aim. Point at the middle of the cup's echo, not its edge (see Class 4's early-finish list).

Sign-off with Dr. Alvear

  • Manual mode: a newcomer hits a cup with the two knobs
  • Ten-shot test recorded
  • Tournament played, score recorded
  • Build log complete: one photo and two sentences per class, plus the range table and graph