Arduino101Pins 引脚
The Arduino101Pins extension provides a general purpose interface to any hardware connected to the Arduino’s digital or analog I/O pins.
Properties
Analog
– Set or get whether the pin is an analog pin (true) or digital pin (false). Default: digital (false).
BluetoothDevice
– The BluetoothLE component with a connection to the Arduino 101.
Output
– Set or get whether the pin is an input or output pin. This only applies to digital pins. Analog pins are read-only. See the Arduino 101 PWM extension for treating digital pins as ‘analog’ outputs. Default: input (false).
Methods
IsSupported
– Check whether the feature is currently available for the device connected via theBluetoothDevice
property. If no device is currently connected, this method will always return false.
ReadPinState
– Read the current state of the pin. After the value is read, it will be reported through thePinStateReceived
event.
RequestPinStateUpdates
– Request updates to the state of the pin. New values will be reported by thePinStateReceived
event.
UnregisterForUpdates
– Stop receiving updates for the pin. Note that there still may be pending notifications to thePinStateReceived
event that will need to be processed after this call.
WritePinState
– Write a new value for the pin. This is only a valid operation if the Output property is set to true. For digital pins, a non zero value will be converted to 1 (HIGH) and a zero value will be converted to 0 (LOW). For analog pins, the value must be between 0 and 1023, inclusive. Any values outside of this range will be truncated. To write analog outputs to digital pins using pulse width modulation, see the Arduino101PWM extension.
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.
Events
PinStateReceived
– After the pin is read or an update is received, thePinStateReceived
event will be run to inform the app about the state of the pin. The value parameter will indicate the pin state. For digital pins, it will be either 0 for off or 1 for on. For analog pins, it will be an integer in the range [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
– After the pin is written, thePinStateWritten
event will be run to indicate a successful operation. The value parameter will indicate the value written to the Arduino from the App Inventor app, not necessarily the value passed by the caller toWritePinState
. For example, in the case of the analog pins the value will be truncated to fit within the range of [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.