hrithik18k/night-light

This circuit employs a light-dependent resistor (LDR) and a transistor (Q1) to automatically turn on an LED in response to low ambient light levels.

Version
1.0.1
License
unset
Stars
0

index.circuit.tsx

PCBPCB preview for index.circuit.tsx
SchematicSchematic preview for index.circuit.tsx
import React from "react"

/**
 * 5 V automatic night light.
 *
 * The LDR and R2 form a light sensor divider. In darkness the LDR resistance
 * rises, SENSOR rises, and Q1 switches on the low-side LED load.
 */
export default function NightLight() {
  return (
    <board width="50mm" height="30mm" layers={2}>
      <schematicsection name="PowerInput" displayName="5 V Power Input" />
      <schematicsection name="LightSensor" displayName="Light Sensor & Filter" />
      <schematicsection name="TransistorSwitch" displayName="Transistor Switch" />
      <schematicsection name="LedLoad" displayName="LED Load" />

      <pinheader
        name="J1"
        pinCount={2}
        gender="male"
        pitch="2.54mm"
        footprint="pinrow2"
        pinLabels={["VCC", "GND"]}
        showSilkscreenPinLabels
        schSectionName="PowerInput"
        pcbX={-21}
        pcbY={0}
        schX={-12}
        schY={0}
      />

      <resistor
        name="R5_LDR"
        resistance="10k"
        footprint="axial_p10mm"
        schSectionName="LightSensor"
        pcbX={-11}
        pcbY={8}
        schX={-4}
        schY={6}
      />
      <resistor
        name="R2"
        resistance="100k"
        footprint="0603"
        schSectionName="LightSensor"
        pcbX={-5}
        pcbY={2}
        schX={0}
        schY={2}
      />
      <capacitor
        name="C1"
        capacitance="100nF"
        footprint="0603"
        schSectionName="LightSensor"
        pcbX={4}
        pcbY={8}
        schX={3}
        schY={0}
        schRotation={90}
      />
      <resistor
        name="R1"
        resistance="47k"
        footprint="0603"
        schSectionName="TransistorSwitch"
        pcbX={-1}
        pcbY={0}
        schX={4}
        schY={4}
      />
      <resistor
        name="R3"
        resistance="100k"
        footprint="0603"
        schSectionName="TransistorSwitch"
        pcbX={5}
        pcbY={0}
        schX={7}
        schY={0}
      />
      <transistor
        name="Q1"
        type="npn"
        footprint="sot23"
        schSectionName="TransistorSwitch"
        pcbX={10}
        pcbY={0}
        schX={10}
        schY={0}
      />
      <resistor
        name="R4"
        resistance="330ohm"
        footprint="0603"
        schSectionName="LedLoad"
        pcbX={15}
        pcbY={7}
        schX={14}
        schY={0}
      />
      <led
        name="LED1"
        color="warm_white"
        footprint="0603"
        schSectionName="LedLoad"
        pcbX={20}
        pcbY={0}
        schX={17}
        schY={0}
      />

      <trace name="power_input" from="J1.VCC" to="net.VCC" />
      <trace name="ground_input" from="J1.GND" to="net.GND" />

      <trace name="ldr_supply" from="R5_LDR.pin1" to="net.VCC" />
      <trace name="ldr_sensor" from="R5_LDR.pin2" to="net.SENSOR" />
      <trace name="threshold_sensor" from="R2.pin1" to="net.SENSOR" />
      <trace name="threshold_ground" from="R2.pin2" to="net.GND" />
      <trace name="filter_sensor" from="C1.pin1" to="net.SENSOR" />
      <trace name="filter_ground" from="C1.pin2" to="net.GND" />

      <trace name="base_drive" from="R1.pin1" to="net.SENSOR" />
      <trace name="base_resistor" from="R1.pin2" to="net.BASE" />
      <trace name="base_pulldown" from="R3.pin1" to="net.BASE" />
      <trace name="pulldown_ground" from="R3.pin2" to="net.GND" />
      <trace name="transistor_base" from="Q1.base" to="net.BASE" />
      <trace name="transistor_emitter" from="Q1.emitter" to="net.GND" />
      <trace name="transistor_collector" from="Q1.collector" to="net.LED_CATHODE" />

      <trace name="led_supply" from="R4.pin1" to="net.VCC" />
      <trace name="led_current_limit" from="R4.pin2" to="LED1.anode" />
      <trace name="led_switch" from="LED1.cathode" to="net.LED_CATHODE" />
    </board>
  )
}