tinsangbeeping/Sub_cor1

This code defines a simple electronic circuit with a resistor and capacitor on a small PCB, and a subcircuit implementing a debounced switch with an LED indicator connected via resistors and traces.

Version
0.0.1
License
unset
Stars
0

subcircuits/Switch_deb_led.tsx

export const ports = ["power", "GND"] as const

export function Switch_deb_led(props: { name: string; schX?: number; schY?: number }) {
  const x = props.schX ?? 0
  const y = props.schY ?? 0

  return (
    <subcircuit name={props.name}>
    {/* // editorSchX={58} */}
    {/* // editorSchY={26} */}
    <resistor
      name="R1"
      resistance="10k"
      footprint="0805"
      schX={x + 2.9}
      schY={y + 1.3}
      schRotation="90deg"
    />
    {/* // editorSchX={60} */}
    {/* // editorSchY={120} */}
    <resistor
      name="R2"
      resistance="10k"
      footprint="0805"
      schX={x + 3}
      schY={y + 6}
      schRotation="90deg"
    />
    {/* // editorSchX={94} */}
    {/* // editorSchY={112} */}
    <resistor
      name="R3"
      resistance="10k"
      footprint="0805"
      schX={x + 4.7}
      schY={y + 5.6}
      schRotation="180deg"
    />
    {/* // editorSchX={168} */}
    {/* // editorSchY={124} */}
    <capacitor
      name="C1"
      capacitance="100nF"
      footprint="0805"
      schX={x + 8.4}
      schY={y + 6.2}
      schRotation="180deg"
    />
    {/* // editorSchX={322} */}
    {/* // editorSchY={122} */}
    <led
      name="LED1"
      color="red"
      footprint="0805"
      schX={x + 16.1}
      schY={y + 6.1}
      schRotation="90deg"
    />
    {/* // editorSchX={0} */}
    {/* // editorSchY={0} */}
    <switch
      name="SW1"
      type="spst"
      footprint="pushbutton"
      schX={x + 0}
      schY={y + 0}
      schRotation="0deg"
    />
    <port
      name="power"
      schX={x + 1.2}
      schY={y + 0}
    />
    <port
      name="GND"
      schX={x + 4.2}
      schY={y + 6.6}
    />
    <trace from=".C1 > .pin2" to=".R3 > .pin1" />
    <trace from=".LED1 > .anode" to=".C1 > .pin2" />
    <trace from=".LED1 > .cathode" to=".C1 > .pin1" />
    <trace from=".R1 > .pin2" to=".R2 > .pin1" />
    <trace from=".R2 > .pin1" to=".R3 > .pin2" />
    <trace from=".R2 > .pin2" to=".C1 > .pin1" />
    <trace from=".R2 > .pin2" to=".GND > .port" />
    <trace from=".SW1 > .pin1" to=".power > .port" />
    </subcircuit>
  )
}