Skip to main content
Tutorials

Building a Simple USB Flashlight

Overview

This tutorial will walk you through building a simple USB flashlight using tscircuit. We'll create a circuit that powers an LED from USB-C, controlled by a push button.

Objectives

A USB flashlight is a simple but practical project that demonstrates core circuit concepts:

  • Power delivery - Using USB-C as a power source (5V VBUS)
  • Current limiting - Protecting the LED with a resistor
  • User interaction - Adding a push button for control

Bill of Materials

ComponentValue/TypePurpose
USB-C ConnectorSMD USB-CPower input (5V)
Push ButtonThrough-holeOn/off control
LEDRed, 0603Light source
Resistor1kΩ, 0603Current limiting

Circuit Design

Understanding the Circuit

The circuit operates on a simple principle:

  1. USB-C provides 5V power on the VBUS pins
  2. When the push button is pressed, current flows through the circuit
  3. The resistor limits current to protect the LED
  4. The LED illuminates when current passes through it

Step 1: USB-C Power Input

First, let's add the USB-C connector which will provide power to our circuit. The USB-C connector has multiple pins, but we only need VBUS (5V power) and GND.

Schematic Circuit Preview

Step 2: Adding the LED and Current-Limiting Resistor

LEDs require a current-limiting resistor to prevent damage. For a typical red LED with a forward voltage of ~2V and desired current of ~3mA:

Resistor calculation:

  • USB voltage: 5V
  • LED forward voltage: ~2V
  • Desired current: ~3mA
  • R = (5V - 2V) / 3mA = 1kΩ
Schematic Circuit Preview

Step 3: Adding the Push Button

The push button connects VBUS to the resistor when pressed, completing the circuit. When released, the circuit is open and the LED turns off.

Schematic Circuit Preview

Step 4: Complete Schematic

Now let's combine all components into the complete circuit:

Schematic Circuit Preview

PCB Layout

With the schematic complete, we can position components on the PCB. The layout is designed for a compact form factor:

  • USB-C connector at the bottom for easy cable access
  • Push button in the middle for ergonomic use
  • LED at the top to project light forward
PCB Circuit Preview

3D Preview

Here's the final 3D preview of the assembled board:

Ordering the PCB

You can order this PCB by exporting the fabrication files and uploading them to JLCPCB. Follow the instructions in Ordering Prototypes.

Modifications and Extensions

Consider these enhancements to customize your flashlight:

  • Brighter LED: Use a white or high-brightness LED (adjust resistor accordingly)
  • Multiple LEDs: Add more LEDs in parallel for increased brightness
  • Different button: Use a latching switch for hands-free operation
  • Battery power: Add a battery holder instead of USB-C for portable use