Devesh36/bicycle-brake-light
A USB‑C rechargeable 1S Li‑ion bicycle brake-light PCB with BQ24074 charging/protection, 3.3V AVR control, ADXL345 motion sensing, six PWM-driven red LEDs, and ISP programming.
- Version
- 0.1.3
- License
- unset
- Stars
- 0
README.md
# Bicycle Brake-Light PCB
**USB-C rechargeable · Motion sensing · Six red LEDs · Built with tscircuit**
A compact bicycle rear-light hardware prototype, designed entirely with tscircuit components and registry imports. An ATtiny85V and ADXL345 provide the hardware for motion-based brake detection; six red LEDs share a PWM-controlled MOSFET driver.

*Routed PCB preview. Open the **PCB**, **Schematic**, **3D** and **BOM** tabs above to explore the design.*
## At a glance
| Feature | Specification |
| --- | --- |
| Board | 90 × 45 mm · two copper layers · 1.6 mm thick |
| Charging input | USB-C, 5 V |
| Battery | Protected 1S Li-ion/LiPo, 4.2 V maximum, with a 10 kΩ thermistor |
| Charger | BQ24074 power-path charger · nominal 100 mA charge current |
| Logic supply | Switched 3.3 V from an AP2112K regulator |
| Controller & sensor | ATtiny85V MCU + ADXL345 accelerometer |
| Light output | Six red LEDs, each with a 120 Ω resistor, switched by an AO3400A |
| Programming | 2 × 3 AVR ISP header at 3.3 V |
| Mounting | Four 3.2 mm holes |
## How the hardware fits together
USB-C supplies the charger, which manages the battery and system power path. The slide switch enables the regulated 3.3 V rail for the controller, sensor and LEDs. The ATtiny85V reads the accelerometer over I²C and can control LED brightness through the MOSFET's PWM input.
**Planned firmware behavior:** a steady rear light with brighter illumination during braking. Brake detection, thresholds and brightness control still need implementation and testing.
## Connections
| Connector | Purpose | Pinout |
| --- | --- | --- |
| **J1** | USB-C charging | 5 V input; USB data is unused |
| **J2** | Battery and temperature sensing | **1:** BAT+ · **2:** NTC · **3:** GND |
| **J3** | AVR ISP programming | **1:** MISO · **2:** 3.3 V · **3:** SCK · **4:** MOSI · **5:** RESET · **6:** GND |
Verify the battery pack's wiring against **J2** before connecting it. Use a **3.3 V** programmer and mount the board with the silkscreened **FORWARD +X** direction pointing forward on the bicycle.
## Build and explore
Install dependencies and open the interactive tscircuit editor:
```sh
bun install
bunx tscircuit dev index.circuit.tsx
```
Generate the circuit and previews, then run the checks:
```sh
bun run build
bun run check
bun run test
```
For local TypeScript checking, install the development tools:
```sh
bun add --dev typescript @types/bun
bun run typecheck
```
| File or folder | Contents |
| --- | --- |
| `index.circuit.tsx` | Board layout, connections and three schematic sheets |
| `imports/` | Component definitions sourced from the tscircuit registry |
| `checks/` | Checks for generated electrical connections and PCB geometry |
| `tscircuit.config.json` | Build and preview configuration |
Build outputs are generated locally in `dist/`. The hosted build uses tscircuit's bundled runtime.
## Prototype status
The PCB layout and routing have been generated and checked locally. **The board has not been fabricated or tested on a bicycle.** Firmware, assembly orientation verification, brake detection calibration and brightness testing are still pending.
Q1 uses an explicit AO3400A pin mapping on a native SOT-23 footprint to work around the native MOSFET component's port issue: **1 gate, 2 source, 3 drain**. The imported regulator, MCU and sensor definitions include conservative courtyards.
## Built from the tscircuit ecosystem
| Components | Registry source |
| --- | --- |
| USB-C connector, BQ24074 charger, battery connector | [gokul/pocket-audio-player](https://tscircuit.com/gokul/pocket-audio-player) |
| Slide switch and red LEDs | [gokul/acoustic-guitar-tuner](https://tscircuit.com/gokul/acoustic-guitar-tuner) |
| AP2112K regulator | [Abse2001/AP2112K_3_3TRG1](https://tscircuit.com/Abse2001/AP2112K_3_3TRG1) |
| ADXL345 accelerometer | [Abse2001/ADXL345BCCZ_RL7](https://tscircuit.com/Abse2001/ADXL345BCCZ_RL7) |
| ATtiny85V controller | [Ayushjhawar8/SparkFun-Qwiic-Joystick](https://tscircuit.com/Ayushjhawar8/SparkFun-Qwiic-Joystick) |
Passives, the ISP header, MOSFET footprint and mounting holes use native tscircuit primitives.