Skip to content

211 GPIO LED ​

211-gpio-led.mc describes a GPIO-driven LED indicator.

GPIO_LED represents a digital output pin from a controller that is not modeled in this small example. The controller also supplies the shared GND connection. The GPIO signal drives D_STATUS.ANODE through the current-limiting resistor R_LED, and D_STATUS.CATHODE returns to GND.

Parse 211-gpio-led.mc:

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 21-digital-io-recipes/211-gpio-led.mc --lib mcode --pass1 --pass2

Generate HTML for 211-gpio-led.mc:

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 21-digital-io-recipes/211-gpio-led.mc --lib mcode --viz -o 21-digital-io-recipes/211-gpio-led.html

Source ​

text
// Example: GPIO LED
// Goal: Connect a digital output to an LED indicator.
// Library focus: GPIO, RES, LED.

module main
{
    io GND
    io GPIO_LED

    RES R_LED(330R, 50V)
    LED D_STATUS(2.0V, 10mA)

    GPIO_LED -> R_LED -> D_STATUS.A
    D_STATUS.K -> GND
}

MCode Bench is the public face of the MCode stack. Closed capabilities are served through the MCode gateway.