From 445a16250dbf75c066cbc8379bd7d6f73727351f Mon Sep 17 00:00:00 2001 From: Vishal Kumar Singh Date: Sat, 16 May 2026 17:29:14 +0530 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFComplete=20USB=20flashlight=20tutorial?= =?UTF-8?q?=20with=20step-by-step=20guide?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Expand the tutorial with detailed explanations covering bill of materials, step-by-step circuit design, resistor calculations for LED protection, PCB layout guidance, and 3D preview. Fixes #555 --- .../building-a-simple-usb-flashlight.mdx | 272 +++++++++++++++++- 1 file changed, 271 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/building-a-simple-usb-flashlight.mdx b/docs/tutorials/building-a-simple-usb-flashlight.mdx index bdf3473..147e4b0 100644 --- a/docs/tutorials/building-a-simple-usb-flashlight.mdx +++ b/docs/tutorials/building-a-simple-usb-flashlight.mdx @@ -6,9 +6,10 @@ description: Learn how to build a simple USB-powered flashlight circuit using ts ## Overview This tutorial will walk you through building a simple USB flashlight using -tscircuit. +tscircuit. We'll create a circuit that powers an LED from USB-C, controlled by a push button. import TscircuitIframe from "@site/src/components/TscircuitIframe" +import CircuitPreview from "@site/src/components/CircuitPreview" { ) } `} /> + +## 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 + +| Component | Value/Type | Purpose | +|-----------|-----------|---------| +| USB-C Connector | SMD USB-C | Power input (5V) | +| Push Button | Through-hole | On/off control | +| LED | Red, 0603 | Light source | +| Resistor | 1kΩ, 0603 | Current 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. + + ( + + + +) +`} /> + +### 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Ω + + ( + + + + + + +) +`} /> + +### 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. + + ( + + .pos", + pin2: "net.VBUS" + }} + /> + + + + + +) +`} /> + +### Step 4: Complete Schematic + +Now let's combine all components into the complete circuit: + + ( + + + .pos", + pin2: "net.VBUS" + }} + /> + + + + + +) +`} /> + +## 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 + + ( + + + .pos", + pin2: "net.VBUS" + }} + pcbX={0} + pcbY={-1} + /> + + + + + +) +`} /> + +## 3D Preview + +Here's the final 3D preview of the assembled board: + + ( + + + .pos", + pin2: "net.VBUS" + }} + pcbX={0} + pcbY={-1} + /> + + + + + +) +`} /> + +## Ordering the PCB + +You can order this PCB by exporting the fabrication files and uploading them to JLCPCB. Follow the instructions in [Ordering Prototypes](/building-electronics/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