Skip to content

Method SetLEDAsync ​

Namespace: Belay.Core.Examples
Assembly: Belay.Core.dll

SetLEDAsync(int, bool) ​

Controls an LED with specified pin and state. Demonstrates parameter substitution in Python code.

csharp
[Task]
[PythonCode("\n        import machine\n        led = machine.Pin({pin}, machine.Pin.OUT)\n        led.value({state})\n        print(f'LED on pin {pin} set to {state}')\n    ")]
Task SetLEDAsync(int pin, bool state)

Parameters ​

pin int

The GPIO pin number for the LED.

state bool

The LED state (True for on, False for off).

Returns ​

Task

Released under the Apache License 2.0.