Led#

Initializing the Led Class#

An LED is created by using the following constructor:

Led(port)

This constructor uses one parameter:

Parameter

Description

port

The 3-Wire Port that the LED is connected to, whether it’s a port on the Brain, or a 3-Wire Expander.

A Brain or 3-Wire Expander must be created first before they can be used to create an object with the LED Class constructor.

# 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.

Class Methods#

on()#

The on() method turns the LED on.

Returns: None

# 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.

Returns: None

# Turn on the LED.
led1.on()

# Wait 2 seconds.
wait(2, SECONDS)

# Turn off LED.
led1.off()