Condujo#

Inicializando la clase Led#

Un LED se crea utilizando el siguiente constructor:

Led(port)

Este constructor utiliza un parámetro:

Parámetro

Descripción

port

El puerto de 3 cables al que está conectado el LED, ya sea un puerto en el Cerebro o un Expandedor de 3 cables.

Primero se debe crear un Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de clase LED.

# Create the Brain.
brain = Brain()
# Construct an LED "led" with the Led class.
led = Led(brain.three_wire_port.a)

This led object will be used in all subsequent examples throughout this API documentation when referring to Led class methods.

Métodos de clase#

on()#

The on() method turns the LED on.

Devoluciones: Ninguna

# Turn on the LED.
led1.on()

# Wait 2 seconds.
wait(2, SECONDS)

# Turn off LED.
led1.off()

off()#

The off() method turns the LED off.

Devoluciones: Ninguna

# Turn on the LED.
led1.on()

# Wait 2 seconds.
wait(2, SECONDS)

# Turn off LED.
led1.off()