Arduino101Pins 引脚
Arduino101Pins 扩展为连接到 Arduino 的数字或模拟 I/O 引脚的任何硬件提供了通用接口。
属性
BluetoothDevice
– 连接到Arduino 101的BluetoothLE组件。
Output
– 设置或获取引脚是输入还是输出引脚。仅适用于数字引脚。模拟引脚是只读的。要将数字引脚作为”模拟”输出,请参阅Arduino 101 PWM扩展。默认值:输入(false)。
方法
IsSupported
– 检查通过BluetoothDevice
属性连接的设备当前是否支持该功能。如果当前没有设备连接,此方法将始终返回false。
ReadPinState
– 读取引脚的当前状态。读取值后,将通过PinStateReceived
事件报告。
RequestPinStateUpdates
– 请求获取引脚状态的更新。新值将通过PinStateReceived
事件报告。
WritePinState
– 为引脚写入新值。仅当Output属性设置为true时才是有效操作。对于数字引脚,非零值将转换为1(HIGH),零值将转换为0(LOW)。对于模拟引脚,值必须在0到1023之间(包含)。超出此范围的任何值将被截断。要使用脉宽调制将模拟输出写入数字引脚,请参阅Arduino101PWM扩展。
Parameters:
* <code>value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The value to write to the pin. Valid values depend on whether the pin is digital or analog.
事件
PinStateReceived
– 当引脚被读取或接收到更新时,将运行PinStateReceived
事件以通知应用程序引脚状态。value参数将指示引脚状态。对于数字引脚,0表示关闭,1表示开启。对于模拟引脚,它将是[0, 1023]范围内的整数。
Parameters:
* <code>value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The value of the pin read from the Arduino. Valid values depend on whether the pin
is digital or analog. For digital pins, a 0 indicates LOW and 1 indicates HIGH.
For analog, an integer in the range of [0, 1023] will be returned.
PinStateWritten
– 当引脚被写入后,将运行PinStateWritten
事件以指示操作成功。value参数将指示从App Inventor应用程序写入Arduino的值,不一定是调用者传递给WritePinState
的值。例如,对于模拟引脚,值将被截断以适应[0, 1023]的范围。
Parameters:
* <code>value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) —
The value written to the Arduino. Valid values depend on whether the pin is
digital or analog. This value is the value written after any transformation by
the extension to fit the range appropriate to the pin type.