🦟

How To BuildMS-2000

A laser turret that learns what a mosquito looks like, follows it, and tags it with a safe laser. The mosquito flashes its eyes on every hit, and the wand saves every run as data. This guide goes from a box of parts to a working turret, one step at a time.

BUILD OCT TO NOV PRINTED PARTS 12 BRAINS 2 × MICRO:BIT LASER CLASS 2, UNDER 1 mW DUE FEB 1

Read this part first

Who does what

Addie's jobs and grown-up jobs

Addie builds and codes. A grown-up handles the hot, sharp, and laser parts. Steps with a grown-up tag need one right there.

Addie

  • Checks the parts and sorts the screws
  • Builds the wand, the base, and the head
  • Teaches the camera the mosquito
  • Writes all the code in MakeCode
  • Designs the pew, boom, beep, and splat sounds
  • Runs every test and keeps the journal

Grown-up

  • Runs the 3D printer and takes parts off the bed
  • Solders the sensor, the eyes, and the laser wires
  • Turns the arm switch on and off
  • Checks the laser lines up before it is ever switched on near people
  • Helps with the tricky code

The big picture

How the MS-2000 works

Two micro:bits work as a team. The one in the turret sees, aims, and fires. The one in the wand feels the hit and keeps score. They talk by radio.

TURRET MOSQUITO AND WAND 1 SeeHuskyLens camera 2 Thinkturret micro:bit 3 Aimpan + tilt servos 4 Firerelay + laser, pew! 5 Feellight sensor in pod 6 Proveeyes flash, splat, save 7 Cheerturret score + song laser dot radio: "HIT" then hunt again

All seven steps happen in less than a second.

Why two micro:bits?

The turret can not see the laser dot land. It only knows where it aimed. To prove a real hit, something has to be inside the target and feel the light. That is the wand's job. Having one machine shoot and a different machine check the score is how real tests stay honest.

See the whole setup in 3D →

Before you start

Tools you need

3D printerGrown-up runs it
Tiny screwdriversPhillips #0, plus a stubby one
Needle-nose pliersTo hold the nuts
Soldering ironGrown-up only
Wire strippersFor the ribbon cable
Hot glue gunGrown-up helps
Tape measureThe 5 foot line
CalipersMeasure parts on arrival
Laptopmakecode.microbit.org
Data USB cableMicro-USB, not charge-only
Needle and threadSew the pod on
Zip ties3 small ones for the wand
FlashlightFor fake laser tests
The journalCursive, every build day

Know your gear

Meet the parts

Lay everything out on a towel before you build. Find each item below so you know what you are holding. Every bought part is also in 3D, with its size.

A B P0P1P23VGND

micro:bit V2 ×2

A tiny computer with 25 lights, two buttons, a touch logo, a speaker, a microphone, a light sensor, and a radio built in. The five big gold rings are where wires connect.

Its job: one is the turret's brain. The other lives in the wand, feels hits, and saves the data.

51.6 × 42 mm · must be V2 (has the gold logo)

micro:bit P0P1P2P8 RELAY HUSKYLENS DC in

Xia mi board

A helper board the micro:bit plugs into. It adds 5 volt pins for servos, a special plug for the camera, a relay, and a jack for the power cable.

Its job: the turret's power station and switchboard. Its relay is the switch that fires the laser.

57 × 87 mm · power switch stays ON

FRONT ID1 BACK SCREEN diallearn

HuskyLens AI camera

A camera with a tiny AI chip. Show it an object, hold the learn button, and it remembers it. Its screen draws a box around the object and it tells the micro:bit where the box is.

Its job: the turret's eyes. It finds the mosquito 30 times a second or so.

52 × 36 mm · 2 × M3 screws · own cable included

brown G · red V · orange S horn

Clutch servo ×3

A small motor that turns to an exact angle, from 0 to 180 degrees, and holds it. The white arm is the horn. A clutch inside slips if a hand grabs it, so the gears do not break.

Its job: one turns the head left and right (pan), one tips it up and down (tilt). The third is a spare.

23 × 12 mm body · 3-pin plug

+− CLASS 2< 1 mW metal case = power

Class 2 laser

A red laser, less than one thousandth of a watt, in a metal tube as thin as a pencil. The label says Class 2: safe enough that your blink protects you, but still never look into it.

Its job: it rides under the camera and flashes for a quarter of a second when the mosquito is centered.

7 mm × 21 mm · 650 nm red · plastic holder only

AmidB slide me

Arm switch

A slide switch smaller than a fingernail. The middle leg connects to one side or the other, depending on where the lever sits.

Its job: the laser safety. It sits in the back wall. When it is off, the laser has no power at all.

About 9 × 4 mm · hot glued in its frame

VINGNDOUT light

Light sensor ×3

A tiny sensor that lets more electricity through when more light hits it. The micro:bit reads it as a number from 0 (dark) to 1023 (very bright).

Its job: it hides inside the mosquito pod and feels the laser dot. Two are spares.

7.8 × 10.6 mm · VIN, GND, OUT

long +short − 220 Ω red red brown

Red LEDs and resistors ×10 each

An LED is a light that only works one way round: long leg to plus. A resistor slows electricity down so the LED does not burn out.

Their job: two LEDs are the mosquito's eyes. Each gets its own 220 ohm resistor.

5 mm LEDs · push in from the back of the pod

volume to P0

Speaker module

A speaker with its own amplifier, which makes quiet signals loud, and a volume knob.

Its job: the pew, the boom, the lock-on beep, and the victory song. It faces the grille in the back of the base.

40 × 40 mm · 4 × M2 · Gravity cable

USB-C USB-A 5,200 mAh power bank, turret 2×AAA, wand

Power bank and battery holders

The power bank is a rechargeable battery, like the one that charges a phone. It has a USB-A port that gives power and a USB-C port that charges it. The small holders take two AAA batteries and have the white plug a micro:bit takes.

Their job: the bank powers the turret and stays inside the base. You charge it through a USB-C port on the side. A small pack powers the wand.

Bank 97 × 46 × 22 mm, 5 V · 2×AAA zip-tied

4-wire ribbon fishing line + printed line clips

Ribbon cable

Four thin wires stuck side by side, soft and bendy. It rides down the fishing line to the mosquito, held on by the little printed clips.

Its job: carries power to the sensor and eyes, and brings the sensor signal back to the wand.

4 wires: 3V, GND, sensor, eyes · write down your colors

M2 kit Gravity cables

Screws and cables

A kit of tiny M2 screws and nuts (M2 means 2 millimeters thick), plus short cables with plugs on both ends.

Their job: the screws hold the printed parts together. The cables connect the speaker.

M3 screws for the camera come in its own box

black foam board

Mosquito and backdrop

A store-bought stuffed mosquito, black foam board, a 1/4 inch dowel, fishing line, and a rod. The white pod gets sewn onto the mosquito.

Their job: the target, and a plain black wall behind it so the camera can see it and the laser has somewhere safe to land.

Foam board 5 mm thick · 30 × 20 in

wand 12 pieces, 5 print batches

Printed parts 12 pieces

Base shell and floor, turntable and yoke, pivot pin, camera head, wand, the white pod cup and its cap, pendulum pivot, backdrop clip, two feet, and cable clips.

Their job: every electronic part lives inside something printed. Step 2 shows the print order.

About 335 g of PLA · 11 g must be white

Where every wire goes

The two wiring maps

Keep this page open while you wire. Side switch off and bank cable unplugged before you change any wire.

Turret

Xia mi board micro:bit HUSKY P0 SVG P1 SVG P2 SVG 5V RELAYCOMNO G DC IN HuskyLens camera Speaker module Pan servo Tilt servo USB-C power bankside switch = main powercharge port: right wall Arm switchback wall, grown-up Class 2 laserin the head clamp 4-pin camera cable side switch P0P1P2 5V to COM NO to + laser − to G

The laser only gets power when the arm switch is on AND the relay clicks. The side switch turns the whole turret on and off.

Mosquito and wand

Wand micro:bit screws clamp wires to the rings 3V GND P0 P1 2×AAA plug in the white socket ribbon, down the line Light sensor VINGNDOUT 220 Ω 220 Ω eyeeye 3V powergroundsensor signaleyes INSIDE THE POD

Long LED leg toward the resistor. Short leg to ground. Both eyes get their own resistor.

What is a circuit?

Electricity only flows around a complete loop: out of the battery, through the part, and back. Every part here has two paths: power in and ground back. Break the loop anywhere and nothing happens. That is exactly how the arm switch works: it breaks the laser's loop.

Hardware

Where every screw goes

Sort the screws into a muffin tin before you start, one cup per row. Pick lengths from the M2 kit when the parts arrive; the two marked lengths matter.

WhereScrewHow manyNotes
Xia mi board to floor plateM24Into the four posts; the plastic makes its own thread
Floor plate to base shellM24Up from underneath into the corner posts
Pan servo to deckM2 + nut2Down through the deck and the servo ears, nut underneath
Speaker to back wallM24Into the four round bosses
Tilt servo to yokeM22From the outside of the right upright
Servo hornshorn screw2Come in the servo bags
Pivot pin to headM2 × 12 + nut1Nut drops into the trap inside the left side of the head
Laser clampM2 × 101From below. It squeezes plastic, never the laser
HuskyLens to headM3 + nut2From the camera's own kit; nuts go in the back traps
Wand micro:bit ringsM24Through 3V, GND, P0, P1; each one clamps a wire
Total2622 × M2 (3 of them with nuts), 2 × M3 with nuts, 2 horn screws. Plus 3 zip ties for the wand.

Part A

Check and print

Measure what arrived, fix the print files if anything is off, then print in five batches. Each batch unlocks the next build steps.

1

Unbox and measure

The weekend the parts arrive · about 1 hour

The print files were drawn from datasheets and photos before anything arrived. A part that is 1 mm different can stop a screw from lining up. Ten minutes with calipers now saves a 3 hour reprint.

  1. Check every item against the shopping list. Tick them off on the parts list PDF.Keep the tiny parts (sensors, LEDs, resistors, switch) in a labeled bag.
  2. Measure the Xia mi board: the distance between its corner holes, both ways.The base expects about 80.2 mm by 50.2 mm between hole centers.
  3. Measure a servo, the 2×AAA pack, the arm switch, the power bank, the in-line switch, the charge port, and the stuffed mosquito. Write every number in the journal.The bank, the in-line switch, and the charge port all fit holes or a cradle in the base, so measure them before the base prints.
  4. Charge the power bank. Plug a USB-C phone charger into its USB-C port. It takes about 2 to 2.5 hours.
  5. Read the Xia mi board for a version number (V1 or V2). You need it for the relay block in Step 11.
  6. Plug a micro:bit into the Xia mi. Plug the 90° adapter and the barrel cable into the bank's USB-A port, the cable into the in-line switch, and the switch into the DC jack. Switch on. Does the micro:bit light up by itself?If it does, the board powers the micro:bit and the spare 2×AAA pack is not needed.
  7. grown-up Voltage check: with both servos sweeping and the laser on, the Xia mi 5V pins must read at least 4.6 V on a meter.The bank gives 5 V, the lowest the DC jack takes. If it reads low, plug into the board's own USB 5 V input instead, with a USB cable that has an in-line switch.
  8. A grown-up compares your numbers with the print files and fixes anything that is off before printing.

What are calipers, and what is tolerance?

Calipers are a ruler with jaws. Close them on a part and read the size to a tenth of a millimeter.

No two parts are exactly the same size. The small wiggle room between "the size it should be" and "the size it really is" is called tolerance. Printed holes are drawn 0.3 mm bigger on each side so parts slide in even when things are a little off.

You are done when

Every part is checked off, the numbers are in the journal, and a grown-up says the print files match.

Journal: the date, what arrived, the numbers you measured, and anything that was different from the plan.

2

Print in five batches

Starts the same weekend · about 10 hours 45 minutes of printing · grown-up

The small, quick batch goes first as a test. Then the parts for the mosquito and wand, so building can start while the big base prints. Each batch has something to learn while it prints on the print plan page.

  1. Batch 1: the white pod and cable clipsThe front of the sensor pod and 11 clips. Must be WHITE PLA.About 35 minutes · 11 g · unlocks step 3
  2. Batch 2: turret head, turntable, and wandTurntable with the tilt yoke, camera head, pivot pin, wand handle, and the back of the pod.About 3.5 hours · 77 g · unlocks steps 3, 4, and 8
  3. Batch 3: base shellThe biggest part. It prints upside down, deck on the bed.About 3 hours 15 minutes · 131 g · unlocks step 6
  4. Batch 4: floor plate and one backdrop footThe board and power bank sit on the floor plate.About 1 hour 55 minutes · 72 g · unlocks step 6
  5. Batch 5: pendulum pivot, backdrop clip, second footThe test rig. The pivot has the 10, 20, and 30 degree marks.About 1.5 hours · 44 g · unlocks step 14
Print plate 4: the white pod cup and cable clips

Batch 1 · white

Print plate 3: turntable and yoke, head, pin, wand, pod cap

Batch 2 · the moving parts

  1. Open the batch's .3mf plate file in Orca-Flashforge and send it to the Adventurer 5M.The settings are already inside: 0.2 mm layers, 3 walls, 15% gyroid infill, brims, no supports.
  2. Wait for the bed to cool before a grown-up takes the parts off.
  3. Peel off the brims. Run a screw into each small hole once to clear it.
  4. Do the checks on the print plan page before starting the next batch.

Why is the inside of a print not solid?

Solid plastic would take hours longer and waste filament. So the printer draws a strong outer skin (the walls) and fills the inside with a wavy pattern called gyroid infill, only 15% full. It works like the honeycomb inside a beehive: light, but strong in every direction.

The base is heavier because it is so big, and that is good. A heavy base does not tip when the head swings fast.

PLA goes soft at about 60°C. A car in the Houston sun gets hotter than that. Never leave the MS-2000 in the car.
See every printed part in 3D →

You are done when

All five batches are printed and cleaned up: 13 big pieces (two of them are backdrop feet) and 11 little clips.

Part B

The mosquito and the wand

Build the target first. Once a flashlight can make the mosquito's eyes flash, you know the hardest part of the proof works, before the turret even exists.

3

Wire the mosquito pod

Batches 1 and 2 done · about 1.5 hours · grown-up solders

The pod is the mosquito's hidden heart: a white cup that glows when the laser hits, a light sensor inside, and two red eyes on top.

laser from the turret white face, 0.8 mm the whole cup glows light sensor, face out 2 resistors, open back eyes, outside the cup ribbon line tab mosquito

The dot can land anywhere on the 40 mm face and still count.

  1. Pick a job for each ribbon wire and write it in the journal: 3V power, ground, sensor signal, eyes.Red for 3V and black for ground are good habits.
  2. Push the two red LEDs into the eye holes from the back of the eye bar. Long legs on the same side.
  3. Solder grown-up the light sensor: 3V wire to VIN, ground wire to GND, signal wire to OUT.
  4. Solder the eyes: each long leg to its own 220 ohm resistor, both resistor ends to the eyes wire, both short legs to the ground wire.Tape or a dab of hot glue over each joint so no bare metal can touch.
  5. Seat the sensor in the cap's pocket, face out, with the wires and resistors in the open back.
  6. Glue the cap into the white cup. Thread the ribbon through the entry on the eye bar.
  7. Tie the fishing line through the tab on top. Double knot.
  8. Sew the pod onto the mosquito's back through the four lug holes. Wait to do this until Step 5 works.

Why a white cup instead of just the sensor?

The light sensor is smaller than a fingernail. The laser dot is about the size of a pea, and it does not always land dead center. At 2 feet and 4 feet it lands about 13 mm off from where the camera aims.

So the sensor hides behind a light collector. White plastic scatters light, so a dot anywhere on the face makes the whole cup glow, and the sensor sees the glow. The eyes sit outside the cup so their own light never fools the sensor.

You are done when

The pod is closed up, four labeled wires come out of it, and no bare metal shows.

4

Build the wand

Same weekend · about 45 minutes

The wand is a handle for the second micro:bit and its batteries. It clips onto the rod for the hand-held demo, and sits by the pendulum pivot for experiments. No soldering here: screws clamp the wires.

3D model of the mosquito test rig: the purple wand at the top, the fishing line down past the pendulum pivot, and the stuffed mosquito with its white pod

Purple wand at the top, ribbon riding the line down to the pod.

  1. Lay the wand micro:bit face up in its bay, gold rings toward the line end. Slide the top edge under the two corner lips.
  2. Strip about 8 mm off the end of each ribbon wire and twist the strands tight.
  3. Clamp each wire: wrap it clockwise around an M2 screw, then drive the screw down through its ring into the boss. 3V wire to 3V, ground to GND, signal to P0, eyes to P1.Clockwise, so tightening the screw pulls the wire in instead of pushing it out.
  4. Put the 2×AAA pack in its bay and push its plug into the white socket on the micro:bit.
  5. Zip-tie the wand to the rod: one tie at the front, two over the battery pack. The V-shaped rails center the rod.
  6. Slide a line clip onto the fishing line every 10 cm and snap the ribbon into each one. Rod clips hold it along the rod.
Stray strands are trouble. If one wire whisker touches the next ring, 3V and ground can short and the batteries get hot. Trim anything sticking out.
See the wand in 3D →

You are done when

With the pack plugged in, the micro:bit lights up, and gently tugging each wire does not pull it out.

5

Code the wand: prove a hit

The next weekend · about 1.5 hours

The first real test of the whole project. By the end, a flashlight flick on the pod makes the eyes flash, plays a splat, and sends "HIT" by radio. A laser dot will do the same thing later.

light number time threshold HIT 1HIT 2HIT 3 room light

A hit is the number jumping above the line. It has to drop back below before the next hit can count.

  1. Go to makecode.microbit.org and start a new project called wand.
  2. Load Program 1 and watch the number scroll. Write down the number in room light.
  3. Shine the flashlight on the white face from about 1 meter. Write down that number too.The two numbers should be far apart. If they are close, check the sensor wires.
  4. Load Program 2. It measures the room when it starts and sets its own threshold.
  5. Flick the flashlight across the pod 20 times. Count the flashes.
  6. If it misses flicks, make the + 100 smaller. If it counts hits with no flashlight, make it bigger.

Program 1: light reader

The micro:bit reads the sensor on P0 and shows the number.

foreverBasic
show number ( analog read pin P0 )Basic + Pins

Program 2: hit detector

Calibrates, then flashes, splats, and radios on every hit.

on startBasic
radio set group 7RadioBoth micro:bits must use the same group number
set threshold to ( analog read pin P0 ) + 100VariablesWhatever the room is, plus a safety gap
show icon: small squareBasic
foreverBasic
if ( analog read pin P0 ) > threshold thenLogic
digital write pin P1 to 1PinsEyes on
radio send string "HIT"Radio
play sound: splat (in background)MusicMake it in the sound editor, Step 12
show icon: XBasic
pause 300 msBasic
digital write pin P1 to 0PinsEyes off
while ( analog read pin P0 ) > thresholdLoopsWait for the light to go away, so one flash is one hit
pause 20 msBasic
show icon: small squareBasic

Analog read pin and digital write pin are in Advanced > Pins. Until the splat sound exists, use "play tone Middle C for 1/8 beat".

What is a threshold, and why does the wand pick its own?

A threshold is a line you draw in a measurement: above it means hit, below it means no hit.

Room light is different on a sunny afternoon than at night, and the tests happen on different days. If the line were stuck at one number, the wand could count hits in a bright room that never happened, or miss real ones in a dim one. So the wand measures the room when it starts and puts the line just above that. Measuring your surroundings instead of guessing is called calibration. Judges love that word.

Try it: cover the pod with your hand and press the reset button on the back. Now uncover it. Does it count a hit by itself? Why?

You are done when

Twenty flashlight flicks give twenty flashes, with no extra hits when the flashlight is off. Now sew the pod onto the mosquito.

Journal: the room number, the flashlight number, your threshold gap, and how many of the 20 flicks counted.

Part C

The turret

Base first, then the pan and tilt head on top, then the wires. The picture below is the whole turret pulled apart, so you can see how the pieces stack.

Exploded 3D model of the turret: floor plate and power bank at the bottom, the pink base shell, the green turntable and yoke, the teal head with the camera, the tilt servo on the right, the laser under the camera
base shell and floor Xia mi board and servos turntable and yoke camera head HuskyLens laser speaker
Open the turret in 3D, tap Explode, and tap any part name →
6

Fill the base

Batches 3 and 4 done · about 1 hour

The base is the turret's body. It holds the brain, the power bank, the speaker, the arm switch, and the pan servo. It stays open underneath until Step 9.

Inside the base: the Xia mi board with the micro:bit standing up at the front left, the dark power bank on the right, the blue pan servo under the deck, the green speaker on the back wall

Board and micro:bit front left, power bank right, speaker on the back wall just left of center, pan servo under the deck.

  1. Screw the Xia mi board onto the four posts on the floor plate, micro:bit end toward the front. 4 × M2.
  2. Stand the turret micro:bit in the board's socket. Its lights will show through the front window.
  3. Screw the speaker to the four bosses on the back wall, just left of center, speaker facing the grille. 4 × M2.Set the volume knob to the middle first. It is hard to reach later.
  4. Press the arm switch into its frame on the back wall so the lever pokes out of the slot. A grown-up tacks it with hot glue.
  5. Push the pan servo up through the pocket in the deck from underneath until its ears sit between the two ribs, shaft on top near the middle.
  6. Screw it down from the top through the deck and the ears, with a nut underneath. 2 × M2 + nuts.
Leave the floor plate off for now. The wires go in first, in Step 9.
See the base in 3D →

You are done when

The speaker, arm switch, and pan servo are solid in the shell, and the board is screwed to the floor plate.

7

Center the servos first

15 minutes · before any horn goes on

A servo can only turn 180 degrees. If the horn goes on while the servo is at one end, the head can only turn one way. So both servos go to the middle, 90 degrees, before anything is attached to them.

0°180°90° horn goes on here 90° each way from the middle
  1. Plug the pan servo into P1 and the tilt servo into P2, brown wire toward G.
  2. Plug the charged power bank into the DC jack (adapter, barrel cable, and in-line switch, like in Step 1) and load the centering program.
  3. Turn the in-line switch on. Both servos twitch to the middle and stay there.
  4. Switch off, and leave them alone until they get their horns in Step 8.

Program 3: center

Start a new project called turret.

on startBasic
servo write pin P1 to 90Pins
servo write pin P2 to 90Pins

How does a servo know what angle to go to?

The micro:bit sends the servo a short pulse about 50 times a second. The length of each pulse is the message: a short pulse means one end, a long pulse means the other end, and in between means in between. A tiny sensor inside the servo checks where the shaft is and keeps turning until it matches. That checking is a feedback loop.

8

Build the pan and tilt head

About 1.5 hours · a stubby screwdriver helps

The moving part. The turntable spins left and right on the pan servo. The yoke on top holds the head, which tips up and down on the tilt servo on one side and a printed pin on the other.

Close-up of the head: camera on top, the red laser under it, the tilt servo on the right side of the yoke, the green turntable below

The finished head

The turret with only the two servos and their horns highlighted: the pan servo under the deck and the tilt servo on the side of the yoke

The two servos highlighted

  1. Press a servo horn into the pocket under the turntable.
  2. Set the turntable on the pan servo with the yoke's open side facing the front, and push it down onto the shaft. Drive the horn screw through the center hole.
  3. Screw the tilt servo to the right upright from the outside, shaft pointing in. 2 × M2.
  4. Press the other horn into the pocket on the head's right side, arm pointing up.
  5. Set the head between the uprights so the horn lands on the tilt shaft, head facing forward and level. Drive the horn screw from inside the head.
  6. Slide the pivot pin through the left upright into the head. Drop an M2 nut in the trap inside, then drive the M2 × 12 screw through the pin. The pin should turn freely in the upright.
  7. Slide the laser into its clamp under the camera spot, lens at the front, label showing, wires out the back. Snug the M2 × 10 screw from below. Snug, not tight.
  8. Bolt the HuskyLens on last: its tab against the plate, lens forward, screen facing back. 2 × M3 with the nuts in the back traps.
  9. Route the cables (camera, tilt servo, laser) through the arch at the back of the yoke and down the round hole in the deck.

Pan and tilt, and why the head has a stop

Pan is turning left and right, like shaking your head no. Tilt is tipping up and down, like nodding yes. With both, the head can point anywhere in front of it. Security cameras and movie cameras use the same idea.

A printed finger on the left side hits a block if the head tips more than about 40 degrees up or 35 down. Even if the code goes wrong, the laser physically cannot point up at a face. A safety that does not depend on code is called a hard stop.

Do not force the head past its stops by hand. The clutch will slip and click, which is fine once, but it is not a toy.
See the head in 3D →

You are done when

Power on with Program 3: the head faces straight ahead and level. Nothing rubs when you gently turn the turntable.

9

Wire the turret and close it up

About 1 hour · grown-up for the laser

Follow the turret wiring map. The laser gets two switches in a row: the arm switch a person controls, and the relay the code controls. Both must be on for any light.

  1. Camera cable into the HuskyLens port.
  2. Speaker into P0, pan servo into P1, tilt servo into P2. Brown or black wires toward G.
  3. grown-up Laser power: a wire from a 5V pin to the arm switch's middle leg; from one side leg to the relay's COM terminal; from the relay's NO terminal to the laser's plus wire. Laser minus wire to a G pin.
  4. Arm switch OFF. Tape a label next to it: ARM.
  5. Set the power bank in its cradle on the right half of the floor plate, ports facing the front. Pull the hook-and-loop strap over it through the two floor slots.Changed Sep 16 by change order MOC-004: the 4×AA pack and its side bay are gone. A rechargeable power bank stays inside instead.
  6. Plug the 90° adapter into the bank's USB-A port, and the barrel cable into the adapter. Coil the extra cable.
  7. Plug the barrel cable into the in-line switch, and the switch into the Xia mi DC jack. Leave the Xia mi's own little power switch ON.
  8. Press the switch rocker into its window in the right wall so it pokes out, under the sloped keeper. This is the main on/off switch now. Hold it there until the floor plate is on: the plate has a small wall the switch sits on.
  9. Charge port: push it through the round hole near the front of the right wall from the outside, screw its nut on from the inside, and plug its cable into the bank's USB-C port.
  10. Screw the floor plate on from underneath. 4 × M2.
  11. Load the relay test and listen.

Program 4: relay test

Add the xia_mi extension first: Extensions, then paste github.com/DFRobot/pxt-DFRobot_xia_mi_Board. Pick V1 or V2 to match the number you found on the board in Step 1.

foreverBasic
relay V2 Actuationxia_mi BoardClick: relay closed
pause 500 msBasic
relay V2 Releasexia_mi BoardClick: relay open
pause 2000 msBasic

What is a relay?

A relay is a switch flipped by a tiny electromagnet instead of a finger. The micro:bit sends a small signal, the magnet pulls a metal arm, and a separate circuit closes. You can hear it: click. That click is the moment the laser fires.

NO means normally open: no connection until the relay clicks. COM is the common terminal that gets connected.

Point the turret at the backdrop before a grown-up slides the arm switch on for the first time.
How to charge: side switch OFF, then plug a USB-C phone charger into the side port. About 2 to 2.5 hours. The bank's four lights are hidden inside, so charge before every session. Never charge while it runs: plugging in can blink the power and restart the micro:bit.

You are done when

The relay clicks every 2.5 seconds. With the arm switch off, no dot. With it on, a red dot blinks on the backdrop. Arm switch back off.

Part D

Teach it and code it

The turret learns the mosquito, follows it, and fires when it is centered. Then the laser gets lined up.

10

Teach the camera the mosquito

About 30 minutes

This is machine learning, done with one button. The camera studies the mosquito from lots of angles and builds its own idea of what a mosquito looks like.

lock-on box ID1 at x 200, y 126 40 right, 6 down: turn right 320 wide × 240 tall, center 160, 120 0,0
  1. Hang the mosquito in front of the black backdrop and switch the turret on.
  2. Check the camera's settings: in General Settings, Protocol Type should be I2C or Auto.
  3. Turn the dial on top until the screen says Object Tracking.
  4. Point the camera so the mosquito sits inside the frame in the middle of the screen.
  5. Press and hold the learn button. While holding it, slowly move the mosquito closer, farther, and turn it a little. Let go.
  6. A box labeled ID1 now follows the mosquito. Swing it around and watch.

What is machine learning?

Normal code is a list of rules someone writes. Nobody can write rules for "what a mosquito looks like." So instead, the camera looks at many examples and finds the pattern itself. That is machine learning.

A camera picture is made of tiny dots called pixels. The camera tells the micro:bit where the middle of the box is, as two numbers: x (across) and y (down). Those are coordinates.

Try it: hold up a different stuffed animal. Does the camera get fooled? Teach it again from more sides and try once more. Write down what happened.
Teach it where it will work: same backdrop, same lights. If the camera forgets after being turned off, save the model in its settings menu, or just teach it again before each session. It takes 30 seconds.

You are done when

The ID1 box stays on the mosquito while it swings, and does not jump to other things in the room.

11

Code the turret: follow the mosquito

About 1.5 hours

The turret looks where the mosquito is, turns a little toward it, and looks again, many times a second. No firing yet.

  1. In the turret project, add the HuskyLens extension (Extensions, search huskylens).
  2. Build Program 5 below and download it.
  3. Swing the mosquito slowly. The head should chase it.
  4. If the head turns away from the mosquito, change that line's minus to plus (or plus to minus).
  5. Find the tilt limits: tip the mosquito high and low and watch where the head stops before it touches its hard stop. Put those angles in the tilt constrain block.Keep a few degrees of room so the servo never pushes against the stop.
  6. If the head shakes back and forth, change both 20s to 30. If it is too slow, try 15.

Program 5: follow

Variables to make first: pan, tilt, x, y.

on startBasic
HuskyLens initialize I2C until successHuskyLens
HuskyLens switch algorithm to Object TrackingHuskyLens
set pan to 90 · set tilt to 90Variables
servo write pin P1 to pan · servo write pin P2 to tiltPins
foreverBasic
HuskyLens request data once and save into the resultHuskyLens
if HuskyLens check if ID 1 frame is on screen from the result thenLogic
set x to HuskyLens get X center of ID 1 frame from the resultVariables
set y to HuskyLens get Y center of ID 1 frame from the resultVariables
set pan to pan − ( x − 160 ) ÷ 20Variables + MathFarther off center means a bigger turn
set tilt to tilt + ( y − 120 ) ÷ 20Variables + Math
set pan to constrain pan between 20 and 160Math
set tilt to constrain tilt between 60 and 120MathChange 60 and 120 to the tilt limits you found
servo write pin P1 to pan · servo write pin P2 to tiltPins

Why divide by 20?

If the mosquito is 40 pixels to the right, 40 ÷ 20 = 2 degrees of turn. If it is 100 pixels away, the turn is 5 degrees. Big miss, big turn. Small miss, small turn. This is called proportional control, and it is how cruise control, thermostats, and drones steady themselves.

Divide by a small number and the turret over-shoots and wobbles. Divide by a big number and it is smooth but slow. Finding the best number is tuning. Write down each number you try and what happened.

You are done when

The head follows a 10 degree swing smoothly and keeps the ID1 box near the middle of the screen.

Journal: every divide number you tried, and the tilt limits you picked.

12

Lock on, fire, and make the sounds

About 2 hours · arm switch OFF while coding

Now the turret fires when the mosquito is in the lock-on box, listens to the wand by radio, and gets its sound effects.

  1. Design the sounds in MakeCode. Drag in a "play sound" block and click the picture to open the sound editor.Pew: a square wave sliding from high to low in a quarter second. Boom: noise, very low, half a second. Splat (for the wand): noise, short, falling. Victory: the built-in melody Power Up.
  2. Add the new parts below to the turret program: the variables, the fire function, the lock-on check, and the radio messages.
  3. Put the splat sound in the wand's Program 2 too.
  4. For testing only, set hunting to true in on start. Step 15 hands that job to the wand.
  5. Arm switch off. Swing the mosquito. Each lock-on should beep, click the relay, and pew.

Program 6: lock on and fire (added to Program 5)

New variables: hunting, boom, score, lastShot.

on start (add these)Basic
radio set group 7Radio
set hunting to false · set boom to false · set score to 0 · set lastShot to 0Variables
relay V2 Releasexia_mi Board
inside forever, after the servo write blocks:Logic
if hunting and absolute of ( x − 160 ) < 12 and absolute of ( y − 120 ) < 12 thenLogicThe mosquito is inside the lock-on box
if ( running time (ms) − lastShot ) > 1000 thenLogicAt most one shot per second
set lastShot to running time (ms)Variables
call fireFunctions
function fireFunctions
play tone High C for 1/16 beat until doneMusicThe lock-on beep
relay V2 Actuationxia_mi BoardLaser on (only if the arm switch is on)
if boom then play sound boom (in background) else play sound pew (in background)Logic + Music
pause 250 msBasic
relay V2 Releasexia_mi BoardLaser off
on radio received receivedStringRadio
if receivedString = "GO": set hunting to true, set score to 0LogicThe wand started a 30 second run
else if "STOP": set hunting to false, relay V2 Release, show number scoreLogic
else if "HIT": change score by 1, play melody Power Up (in background)Logic
else if "BOOM": set boom to true · else if "PEW": set boom to falseLogic

Why wait a whole second between shots?

The camera sends a new picture many times a second. Without a wait, the turret would fire again and again at one lock-on, and one real hit would look like five. The cooldown makes every shot a separate try, so the data is fair. It also gives the eyes time to flash and the splat time to play.

What is sound, and how does the editor make a pew?

Sound is air shaking. How many times it shakes each second is its frequency, measured in hertz. A high shake is a high pitch. A pew is a high pitch that slides down fast. A boom is a very low, rough shake called noise.

You are done when

With the arm switch off, every lock-on beeps, clicks, and pews, no more than once a second. A flashlight flick on the pod makes the turret play Power Up.

13

Line up the laser

About 45 minutes · grown-up runs the arm switch

The laser sits 38 mm below the camera lens, aimed up a tiny bit (about 2.4 degrees) so the two lines cross 3 feet away, the test distance. Now check that the dot really lands on the white face.

camera laser 38 mm 2 ft3 ft4 ft 13 mm lowdead center13 mm high white face: 40 mm tall

Not to scale: the real angle is much flatter. From 2 to 4 feet the dot stays on the face.

  1. Hang the mosquito so the pod is at camera height, 3 feet from the lens, backdrop behind it.
  2. Wand on, turret on, hunting on (testing setup from Step 12).
  3. grown-up Arm switch on. Hold the mosquito still in the middle of the camera's view.
  4. Watch where the dot lands on each shot. Every shot should make the eyes flash.
  5. If the dot is off to one side, arm switch off, loosen the clamp screw, slide a thin strip of paper along one side of the laser to nudge it, tighten, and try again.
  6. Repeat at 2 feet (the fair table) and 4 feet. Arm switch off when you are done.

Why does the dot move with distance?

Two straight lines that are not side by side can only cross at one point. The camera and laser are 38 mm apart, so they cross at 3 feet and drift apart before and after. The white face is 40 mm tall, big enough to catch the dot from 2 to 4 feet. That is why every test runs at 3 feet, and why the fair table keeps the mosquito 2 to 3 feet from the camera.

You are done when

Ten shots out of ten make the eyes flash at 2, 3, and 4 feet, with the mosquito held still.

Journal: where the dot landed at each distance and anything you had to fix.

Part E

The test rig and the data

A backdrop, a pendulum that swings the mosquito the same way every time, and a wand that runs each test and saves the numbers by itself.

14

Set up the backdrop and pendulum

Batch 5 done · about 45 minutes

For experiments, nobody holds the mosquito. It hangs from a pivot and swings from a marked angle, so every run starts exactly the same way. That is what makes the test fair.

camera height wand 20° 3 ft2 ft0 3 ft for every test run,2 to 3 ft on the fair table black foam board 1/4 in dowelpivot mosquitofeet

Pull the mosquito to the angle mark, let go, and it swings side to side in front of the turret.

  1. Stand the foam board in the two printed feet, one near each end.
  2. Push the clip onto the middle of the top edge, and slide the dowel through it so it sticks straight out toward the turret.
  3. Clamp the pendulum pivot near the end of the dowel, angle marks facing the turret.
  4. Loop the fishing line over the peg and adjust it until the white pod hangs at camera height.
  5. Set the wand beside the pivot on the dowel, with the ribbon running down the line.
  6. Tape a tape measure to the table from the line toward the turret. Mark 3 feet (every test run) and 2 feet (the fair table). Put a strip of tape where the turret's front edge goes for each.
  7. Learn the marks: one hole next to a notch is 10 degrees, two holes 20, three holes 30.
  8. Cut three target covers from black paper, each just bigger than the pod face, with a round hole in the middle: 40 mm, 20 mm, and 10 mm. Tape the 40 mm one on for the speed test.Same outside size on all three, so the camera sees the same mosquito and only the target changes.

Why does a bigger angle make a faster mosquito?

Pulling the mosquito back to a higher angle lifts it higher, which gives it more energy. At the bottom of the swing, that energy turns into speed. About twice the angle gives about twice the speed.

Here is the surprise: for small swings, the time for one swing hardly changes. Only the speed does. Galileo noticed this more than 400 years ago watching a lamp swing in a church.

Try it: count the swings in 10 seconds from 10 degrees, then from 30 degrees. Write both numbers down. Are they close?
Beam direction: set the table up so the laser points at the wall of the room, not at a doorway or a couch where people sit.
See the pendulum pivot in 3D →

You are done when

The mosquito swings smoothly from each mark, the pod passes through camera height, and the 3 foot mark is on the table.

15

Code the wand: the run recorder

About 1.5 hours

The wand becomes the boss of every run. It picks the test, starts the turret, times 30 seconds, counts hits, and saves one row of data that stays even when the batteries come out.

A B A: pickthe testspeed 10, 20, 30size 40, 20, 10 B: runnumber1 to 5 logo: pew or boom A + B together: START 30 seconds, then it beeps and saves
  1. In the wand project, add the datalogger extension (Extensions, search datalogger).
  2. Build Program 7. It replaces Program 2, but keeps its hit detector.
  3. In the turret program, set hunting back to false in on start. Now the turret only fires during a run.
  4. Download both. Press A a few times, then B, then A and B together. The turret should start hunting, and stop after 30 seconds.

Program 7: run recorder (wand)

Variables: names, pick, run, running, start, hits, first, light, threshold, boom.

on startBasic
radio set group 7Radio
set columns "setting" "run" "hits" "first hit" "light"Data Logger
set names to array of "speed 10" "speed 20" "speed 30" "size 40" "size 20" "size 10"Variables + Arrays
set pick to 0 · set run to 1 · set running to false · set threshold to 1023Variables
on button A pressedInput
if not running: change pick by 1, if pick > 5 set pick to 0, show string ( names get value at pick )Logic
on button B pressedInput
if not running: change run by 1, if run > 5 set run to 1, show number runLogic
on logo pressedInput
set boom to not boom; if boom radio send string "BOOM" else radio send string "PEW"Logic
on button A+B pressedInput
if not running thenLogic
set light to analog read pin P0VariablesThe room, measured right now
set threshold to light + 100 · set hits to 0 · set first to 0Variables
set start to running time (ms) · set running to trueVariables
radio send string "GO"Radio
show icon: targetBasic
foreverBasic
if ( analog read pin P0 ) > threshold thenLogic
digital write pin P1 to 1 · play sound splat (in background)Pins + Music
if running: change hits by 1; if hits = 1, set first to ( running time (ms) − start ) ÷ 1000LogicSeconds to the first hit
radio send string "HIT" · pause 300 ms · digital write pin P1 to 0Radio
while ( analog read pin P0 ) > threshold: pause 20 msLoops
if running and ( running time (ms) − start ) > 30000 thenLogic30 seconds are up
set running to falseVariables
radio send string "STOP"Radio
log data: setting = names get value at pick, run = run, hits = hits, first hit = first, light = lightData Logger
play tone High C for 1 beat · show number hitsMusic + Basic

When the wand is not in a run, a hit still flashes the eyes and splats. That is the hand-held demo mode.

What is data logging?

Logging means writing down a measurement every time something happens, automatically. The micro:bit V2 saves each row in its own memory, which keeps it even with the batteries out.

Plug the wand into a computer and open the file called MY_DATA on the MICROBIT drive. It shows a table, a graph, and a button to download the numbers for a spreadsheet.

Never add a "delete log" block. Download MY_DATA after every test day and keep a copy. Also write each run on the paper sheet, as a backup.

You are done when

A+B starts the turret, it stops by itself after 30 seconds, and a new row appears in MY_DATA.

16

The first full test

About 1 hour · then practice until Dec 11

A dress rehearsal. Five practice runs, just like a real experiment, to find anything silly before the numbers count.

  1. Charged power bank in the turret, fresh batteries in the wand. Turret on the 5 foot mark, room lights on.
  2. Teach the camera the mosquito if it has forgotten.
  3. On the wand: A until it says speed 10, B to run 1.
  4. grown-up Arm switch on. Pull the mosquito to the 10 degree mark.
  5. Let go, then press A+B. Hands off. Wait for the beep.
  6. Write the hits on the paper data sheet. Press B for the next run. Do five.
  7. Arm switch off. Plug in the wand, open MY_DATA, and check the five rows match the paper.
  8. Take a photo of the setup for the board.

Why practice runs do not count

Practice is for finding problems: a loose wire, a camera that forgot, a threshold that is too tight. Fix them now. Once the real tests start on December 12, every run counts, even the bad ones, and you only redo a run if something broke.

You are done when

Five runs are saved, the file matches the paper, and nothing broke. The MS-2000 is built. Next: the hypothesis is due December 9, and the experiments start December 12.

Journal: the five practice numbers, what went wrong, and how you fixed it.

When it misbehaves

Fixing it

Find what you see, try the fix. Write down every problem in the journal; judges like hearing how you solved them.

What you seeMost likely causeWhat to do
Nothing happens at allPowerSide switch on? Bank charged? Xia mi power switch on? Adapter pushed all the way in?
micro:bit will not take the codeCableMany micro-USB cables only charge. Use one you know moves data.
Camera screen works, turret does not moveNo data from the cameraCheck the camera cable is in the HuskyLens port and Protocol Type is I2C or Auto. Is ID1 learned?
Head turns away from the mosquitoSign is backwardsSwap minus and plus in that servo's line in Program 5.
Head shakes back and forthTurning too much each timeDivide by a bigger number: 30 instead of 20.
Head chases other thingsCamera learned the roomForget and re-learn in front of the black backdrop. Clear the table behind the mosquito.
Servo buzzes at one endPushing against a stopTighten the constrain numbers by a few degrees.
Relay does not clickWrong board versionChange V2 to V1 in the relay blocks, or the other way.
Relay clicks, no laserArm switch off, or a wireGrown-up checks: arm switch on, 5V to the switch, COM and NO on the right terminals, laser minus to G.
Laser hits, eyes do not flashThreshold too highChange + 100 to + 60. Check the dot is on the white face.
Eyes flash with no laserThreshold too low, or room changedStart a new run (A+B) so the wand measures the room again. Try + 150.
Eyes never lightLED in backwardsLong leg must go to the resistor side. Grown-up re-solders.
Turret never hears the wandRadio groupBoth programs must say radio set group 7. Keep them within a few meters.
One hit counts twiceMissing the wait loopCheck the "while ... pause 20" loop is in the wand's forever.
A screw spins and will not tightenStripped plasticUse the next longer screw, or a grown-up adds a drop of glue and waits.
Hits drop during a test dayNot the powerThe bank holds a steady 5 V, so this should not come from power. If the bank runs empty, the turret stops all at once. Charge it before each test day.

Words to know

Say these like a scientist

Judges ask what words mean. Here they are in one place.

MicrocontrollerA tiny computer that runs one program over and over. The micro:bit is one.
Machine learningA computer finding a pattern from examples instead of written rules.
PixelOne tiny dot in a camera picture. The HuskyLens sees 320 across and 240 down.
CoordinatesTwo numbers that say where something is: x across, y down.
ServoA motor that turns to an exact angle and holds it.
Pan and tiltTurning left and right, and tipping up and down.
Feedback loopLook, adjust, look again, over and over.
Proportional controlA bigger miss gets a bigger correction.
TuningTrying numbers until a machine behaves just right.
Hard stopA physical block that works even if the code is wrong.
RelayA switch flipped by an electromagnet. The click fires the laser.
CircuitA complete loop that electricity flows around.
ResistorA part that slows electricity down to protect an LED.
AnalogA measurement with a whole range of answers, like 0 to 1023.
ThresholdThe line in a measurement between yes and no.
CalibrationMeasuring your surroundings before you start, instead of guessing.
Light collectorThe white cup that turns a dot anywhere on its face into a glow.
CooldownA wait after each shot so one hit is never counted twice.
FrequencyHow many times a sound shakes each second, in hertz.
Radio groupA channel number. Only micro:bits on the same group hear each other.
Data loggingA machine writing down its own measurements.
ToleranceHow far a real part can be from its drawing and still fit.
InfillThe honeycomb pattern inside a 3D print.
Class 2 laserA visible laser under 1 milliwatt. Your blink protects you, but never stare.

Everything else

The other pages