README.md
# Infrared battle-tag board — Rev A
A 60 × 45 mm, two-layer tscircuit design. Build two identical boards for the game. Designed from the supplied component list; no reference schematic or board image was provided.


## Hardware
- External **switched 3×AAA alkaline holder**, connected to J1: pin 1 positive, pin 2 GND. Design input range: 3.3–4.8 V. D1 provides series reverse-polarity protection; VCC is the battery voltage minus its forward drop.
- ATtiny1616-SN in SOIC-20, 100 nF local bypass plus 47 µF bulk capacitance.
- TSAL6200 940 nm emitter, driven by MMBT2222ALT1G through a 68 Ω resistor. Typical nominal current is about `(4.5 − 0.3 − 1.35 − 0.2) / 68 ≈ 39 mA`; it varies with batteries and device drops. A 680 Ω base resistor and 100 kΩ pull-down provide drive and a default-off state.
- TSOP38238 demodulating receiver with a 100 Ω / 4.7 µF supply filter.
- Three red life LEDs with individual 1 kΩ resistors. Fire and new-game buttons have external 10 kΩ pull-ups.
- Four 2.5 mm mounting holes. The battery holder and UPDI programmer are external.
| Function | ATtiny1616 SOIC pin | Port |
|---|---:|---|
| IR carrier output | 2 | PA4 |
| Life LEDs 1 / 2 / 3 | 3 / 4 / 5 | PA5 / PA6 / PA7 |
| Fire, active low | 10 | PB1 |
| New game, active low | 11 | PB0 |
| UPDI | 16 | PA0 |
| Receiver output, active low | 17 | PA1 |
| VCC / GND | 1 / 20 | supply |
J2 is **1 = VCC, 2 = UPDI, 3 = GND**. Use a programmer that supports the target supply voltage. VCC is a direct target rail connection; use it as voltage reference when the battery powers the board, or disconnect the battery when powering from the programmer.
## Assembly values
| Ref | Value / part | Package / requirement |
|---|---|---|
| U1 | ATtiny1616-SN, C614136 | SOIC-20 wide |
| U2 | TSOP38238, C141632 | Through-hole, 1 OUT / 2 GND / 3 VS |
| Q1 | MMBT2222ALT1G, C82460 | SOT-23, 1 B / 2 E / 3 C |
| D1 | 1N5819WS, C191023 | Imported SOD-323 footprint |
| LED1 | TSAL6200, C55528 | 5 mm through-hole; observe A/K markings |
| LED2–4 | Red LEDs | 0805, anode = pad 1 |
| SW1–2 | TS-1102S-C-C-B, C381039 | 6 × 6 mm SMD; corrected internal pairs |
| R1 | 68 Ω, 5% or better | 1206, at least 0.25 W |
| R2 | 680 Ω | 0603 |
| R3 | 100 kΩ | 0603 |
| R4 | 100 Ω | 0603 |
| R5–7 | 1 kΩ | 0603 |
| R8–9 | 10 kΩ | 0603 |
| C1 | 47 µF ceramic | 1210, ≥10 V; select ≥22 µF effective at 5 V bias |
| C2 | 100 nF | 0603, X7R, ≥10 V |
| C3 | 4.7 µF | 0805, X7R/X5R, ≥10 V |
| J1 / J2 | 2 / 3 pins | 2.54 mm single-row headers |
Aim the emitter and receiver optical faces toward the opponent; confirm the upright/bent-lead arrangement against the intended enclosure. The receiver and emitter sit at opposite ends of the board edge to help mechanical separation. Range and self-hit rejection require physical testing.
## Reproduce and inspect
```sh
bun install --frozen-lockfile
bunx tsc --noEmit
bunx tsci check netlist index.circuit.tsx
bunx tsci check schematic-placement index.circuit.tsx
bunx tsci check placement index.circuit.tsx
bunx tsci build index.circuit.tsx --pcb-png --schematic-png --svgs
bunx tsci check shorts dist/index/circuit.json --mode gerber
bunx tsci check shorts dist/index/circuit.json --mode pcb
bunx tsci dev index.circuit.tsx
```
Entry point: [index.circuit.tsx](index.circuit.tsx). Exported circuit JSON and vector snapshots are in `dist/index/`. [ISSUES.md](ISSUES.md) contains reproducible import defects, cropped evidence, and the final checks. The scripts explicitly target the real board so the deliberately unsafe bug reproductions under `evidence/` are not mistaken for production designs.
Downloads: [Gerbers and drills](gerbers.zip), [corrected KiCad project](infrared-battle-tag.kicad.zip). Use the corrected KiCad ZIP at the project root: the raw CLI ZIP in `dist/index/` omits the child schematic (documented in ISSUES.md). The corrected archive includes the child sheet and has been checked for missing references; it has not been rendered in KiCad desktop. Generated pick-and-place rotations are unverified and need assembly review.
## Firmware and bring-up
This deliverable is hardware, with no programmed firmware. Use the internal oscillator at **5 MHz** for margin over the operating supply range, retain the UPDI fuse function, and enable brown-out handling. Generate a 38 kHz carrier on PA4; send bounded bursts with gaps compatible with the TSOP38238, rather than an unbroken carrier. A NEC-style envelope is an appropriate starting protocol. Debounce buttons, maintain three lives, and ignore local receive events during transmission and the receiver recovery interval. Validate timing and hit range with two boards.
Before assembly release, inspect the fabrication files and selected component footprints. On first bring-up, check VCC-to-GND resistance unpowered, use a current-limited supply, confirm the protected rail and receiver rail, program over UPDI, then scope the carrier and receive output. The board is an electrically checked prototype design, not a bench-tested product.
Manufacturer references: [Microchip MCU datasheet](https://ww1.microchip.com/downloads/aemDocuments/documents/MCU08/ProductDocuments/DataSheets/40001893B.pdf), [Vishay receiver](https://www.vishay.com/docs/82491/tsop382.pdf), [Vishay emitter](https://www.vishay.com/docs/81010/tsal6200.pdf), [Onsemi transistor](https://www.onsemi.com/pdf/datasheet/mmbt2222lt1-d.pdf).