数字输出#

初始化 DigitalOut 类#

使用以下构造函数创建数字输出:

DigitalOut(port)

此构造函数使用一个参数:

范围

描述

port

数字输出连接到的 3 线端口,无论它是 大脑 上的端口,还是 3 线扩展器 上的端口。

必须先创建 Brain3-Wire Expander,然后才能使用 DigitalOut 类构造函数创建对象。

# Create the Brain.
brain = Brain()
# Construct a Digital Output "digout" with the
# DigitalOut class.
digout = DigitalOut(brain.three_wire_port.a)

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

类方法#

set()#

The set(value) method sets the value of the Digital Output.

参数

描述

价值

The value to set for the Digital Output, 1, True, 0, or False.

**返回:**无。

# Set Digital Output to True.
digout.set(True)