WARNING: This page is for archival purposes only. Some links may be broken, guides may be outdated, and software extensions for App Inventor may be old, resulting in non-functioning apps. For our latest IOT materials, please click here.
The Arduino101Pins extension provides a general purpose interface to any hardware connected to the Arduino’s digital or analog I/O pins.
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).IsSupported
– Check whether the feature is currently available for the device connected via the
BluetoothDevice
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 the
PinStateReceived
event.RequestPinStateUpdates
– Request updates to the state of the pin. New values will be reported by the
PinStateReceived
event.UnregisterForUpdates
– Stop receiving updates for the pin. Note that there still may be pending notifications to the
PinStateReceived
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:
value
(number) —
The value to write to the pin. Valid values depend on whether the pin is digital or analog.PinStateReceived
– After the pin is read or an update is received, the PinStateReceived
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:
value
(number) —
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, the PinStateWritten
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 to
WritePinState
. For example, in the case of the analog pins the value will be
truncated to fit within the range of [0, 1023].
Parameters:
value
(number) —
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.