diff --git a/docs/tutorials/building-a-simple-usb-flashlight.mdx b/docs/tutorials/building-a-simple-usb-flashlight.mdx index bdf34737..8043458f 100644 --- a/docs/tutorials/building-a-simple-usb-flashlight.mdx +++ b/docs/tutorials/building-a-simple-usb-flashlight.mdx @@ -1,42 +1,285 @@ ---- -title: Building a Simple USB Flashlight -description: Learn how to build a simple USB-powered flashlight circuit using tscircuit with a push button, LED, and USB-C connector. ---- - -## Overview - -This tutorial will walk you through building a simple USB flashlight using -tscircuit. - -import TscircuitIframe from "@site/src/components/TscircuitIframe" - - { - return ( - - - .pos", pin2: "net.VBUS" }} - pcbX={0} - pcbY={-1} - /> - - - - - - - ) -} -`} /> +--- +title: Building a Simple USB Flashlight +description: Build a tiny USB-powered flashlight with a USB-C connector, pushbutton, LED, and current-limiting resistor. +--- + +## Overview + +This tutorial walks through a tiny flashlight circuit that turns on when you +press a momentary pushbutton. + +The design is intentionally small: + +1. USB-C provides 5V power +2. A pushbutton acts as the on/off control +3. An LED provides the light source +4. A resistor limits LED current + +import CircuitPreview from "@site/src/components/CircuitPreview" + +## 1. Start with the full circuit + +The complete circuit is shown below so you can see the end result first. + + { + return ( + + + + .pos", + pin2: "net.VBUS", + }} + pcbX={0} + pcbY={-1} + /> + + + + + + + + + ) +} +`} /> + +## 2. Add the power input + +USB-C gives us a simple 5V source. In this board, we only use `VBUS` and `GND`. +That keeps the example focused on the flashlight path instead of USB data. + +If you want the flashlight to be more robust, keep the USB-C connector close to +the edge of the board and give it enough mechanical support in the final layout. + + ( + + + +) +`} /> + +## 3. Add the pushbutton + +The button connects `VBUS` to the resistor path only while it is pressed. That +means the LED stays off until you actively hold the switch. + + ( + + + + .pos", + pin2: "net.VBUS", + }} + schX={7} + schY={0} + /> + +) +`} /> + +## 4. Limit the LED current + +The resistor keeps the LED from drawing too much current. A `1k` resistor is a +safe, beginner-friendly value that produces a visible but gentle light output. + +The exact value is not sacred here. If you want a brighter light, you can lower +the resistor, but you should keep an eye on LED current and heat. + +## 5. Add the LED + +The LED sits after the resistor so current flows through it only when the button +is pressed. + + ( + + + + .pos", + pin2: "net.VBUS", + }} + schX={-2} + schY={0} + /> + + + + + + + + +) +`} /> + +## 6. Place the parts on the PCB + +This layout keeps the USB-C connector at the bottom, the button near the top +center, and the LED near the top edge so the light is easy to see. + + ( + + + + .pos", + pin2: "net.VBUS", + }} + pcbX={0} + pcbY={-1} + /> + + + + + + + + +) +`} /> + +## 7. Bill of materials + +| Reference | Part | Notes | +| --- | --- | --- | +| J1 | USB-C connector | Brings in 5V power | +| SW1 | Pushbutton | Momentary on/off control | +| R1 | 1k resistor, 0603 | Limits LED current | +| LED1 | Red LED, 0603 | Light source | + +## 8. How it works + +When the button is not pressed, the LED path stays open and no current flows. +When you press the button, `VBUS` reaches the resistor, then the LED, then +ground. The resistor keeps the current in a safe range so the LED does not get +overdriven. + +## 9. Next steps + +- Change `LED1` to green or blue if you want a different look +- Try a different resistor value if you want more or less brightness +- Add a tiny enclosure or mounting holes if you want it to feel like a real + product