002 Resistor LED
002-resistor-led.mc places a resistor and LED in series across the source. RES R_LIMIT(330R, 50V) uses Ωs (R) and a voltage rating; LED D_STATUS(2V, 20mA) supplies the LED forward voltage and current. A connection may contain several operands:
text
PWR.1 -> R_LIMIT -> D_STATUS -> PWR.2For ordinary two-pin components, a bare instance in a chain enters one pin and leaves the other. The current path is therefore source positive, resistor, LED, then source ground. The library pin order also places the LED anode toward the resistor and its cathode toward ground.
bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 00-getting-started/002-resistor-led.mc --lib mcode --pass1 --pass2
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 00-getting-started/002-resistor-led.mc --lib mcode --viz -o 00-getting-started/002-resistor-led.htmlSource
text
// Example: Resistor LED
// Goal: Show a simple LED indicator with a current-limiting resistor.
// Library focus: RES, LED, DC.
module main
{
DC.SRC PWR(5V, 500mA)
RES R_LIMIT(330R, 50V)
LED D_STATUS(2.0V, 20mA)
PWR.1 -> R_LIMIT -> D_STATUS -> PWR.2
}