Microbit 板载引脚

« 返回首页

Microbit Io Pin:板载引脚

The Microbit_Io_Pin component lets users configure the BBC micro:bit’s analog pins for input and output, and to read, write, and request notifications for the I/O pin states.

More links:<ul><li>RGB LED control: sample project and tutorial.</li><li>Read knob status: sample project and tutorial.</li><li>Read switch status: sample project and tutorial.</li></ul>

Properties

  • BluetoothDevice – The BluetoothLE component connected to the micro:bit device (setter).

get Microbit_Io_Pin1 BluetoothDevice

set Microbit_Io_Pin1 BluetoothDevice  to

Methods

  • ReadPinADConfiguration – Read the state of the micro:bit’s pin configuration, specifically whether each pin is configured as digital (0 or 1) or analog (0 to 255). After a successful read, the PinADConfigurationReceived event will be run.

call Microbit_Io_Pin1 ReadPinADConfiguration

  • ReadPinData – Read a single sample of the pin states from the micro:bit. On successful read, the PinDataReceived event will be run. Prior to reading the pins, one should configure the pins for input using the WritePinIOConfiguration method.

call Microbit_Io_Pin1 ReadPinData

  • ReadPinIOConfiguration – Read the current input/output configuration of the micro:bit’s pins. After a successful read, the PinIOConfigurationReceived event will be run.

call Microbit_Io_Pin1 ReadPinIOConfiguration

  • RequestPinDataUpdates – Request updates to any micro:bit pins configured as input pins. After requesting updates, the PinDataReceived will be run whenever the micro:bit reports changes to its input pins.

call Microbit_Io_Pin1 RequestPinDataUpdates

  • StopPinDataUpdates – Stop receiving updates about the state of the micro:bit’s I/O pins. Note that there may be pending updates that have not been processed that will result in additional PinDataReceived events.

call Microbit_Io_Pin1 StopPinDataUpdates

  • WritePWMControl – Writes the PWM control field on the micro:bit. The PWM control field is a variable length array of one or two instances of a data structure containing a 1-byte pin field (range 0-19), a 2-byte value field (range 0-1024), and a 4-byte period field (in milliseconds).

Parameters:

 * <code>PWM\_Control\_Field</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   The PWM control field data as defined in the WritePWMControl method description.

call Microbit_Io_Pin1 WritePWMControlPWM_Control_Field

  • WritePinADConfiguration – The WritePinADConfiguration is used to configure whether pins on the micro:bit are analog or digital. The Pin\_AD\_Config\_Value is composed of three bytes that represent 19 bits, one for each pin on the micro:bit. A 0 bit indicates a digital pin and a 1 bit indicates an analog pin. The WrotePinADConfiguration event will be run after successfully writing a new pin configuration.

Parameters:

 * <code>Pin\_AD\_Config\_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   A list of 8-bit values that are composed into a 19-bit mask, one bit per pin on the micro:bit.

call Microbit_Io_Pin1 WritePinADConfigurationPin_AD_Config_Value

  • WritePinData – The WritePinData is used to set the output values of the micro:bit’s pins if configured as output pins using the WritePinIOConfiguration method. After the pins are written, the WrotePinData event will be run.

Parameters:

 * <code>IO\_Pin\_Data</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#makealist">_list_</a>) &mdash; A list of up to 19 values from 0-255 to be output to the micro:bit's pins.

call Microbit_Io_Pin1 WritePinDataIO_Pin_Data

  • WritePinIOConfiguration – The WritePinIOConfiguration method is used to configure the micro:bit’s pins for input or output. The Pin\_IO\_Config\_Value parameter should be a 3-element list where each element is a number from 0-255 composing a 19-bit bitmask. A 0-bit indicates an output and a 1-bit indicates an input.

Parameters:

 * <code>Pin_IO_Config_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   A list of 8-bit values that are composed into a 19-bit mask, one bit per pin on the micro:bit.

call Microbit_Io_Pin1 WritePinIOConfigurationPin_IO_Config_Value

Events

  • PinADConfigurationReceived – The PinADConfigurationReceived event is run after a successful call to the ReadPinADConfiguration method is returned by the micro:bit.

Parameters:

 * <code>Pin\_AD\_Config\_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   A list of analog/digital pin states configured on the micro:bit.

when Microbit_Io_Pin1 PinADConfigurationReceived Pin_AD_Config_Value do

  • PinDataReceived – The PinDataReceived event will be run after the micro:bit sends the status of its input pins. This will typically follow calls to ReadPinData or RequestPinData.

Parameters:

 * <code>IO_Pin_Data</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#makealist">_list_</a>) &mdash;
   The state of the micro:bit's input pins. Pins not configured for input will have 0 value.

when Microbit_Io_Pin1 PinDataReceived IO_Pin_Data do

  • PinIOConfigurationReceived – The PinIOConfigurationReceived event will be run after the micro:bit’s pins’ input/output configuration is read. Pin\_IO\_Config\_Value will be a list of three bytes valued from 0-255 composing a 19-bit mask indicating the input or output state of each of the 19 pins provided by the micro:bit. A 0 bit indicates output and a 1 bit indicates input.

Parameters:

 * <code>Pin\_IO\_Config\_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   A list of 8-bit values that are composed into a 19-bit mask, one bit per pin on the micro:bit.

when Microbit_Io_Pin1 PinIOConfigurationReceived Pin_IO_Config_Value do

  • WrotePWMControl – The WrotePWMControl event is run after a successful write to the micro:bit’s pulse-width modulation control service. The value of the control field that was written will be passed as the PWM\_Control\_Field.

Parameters:

 * <code>PWM\_Control\_Field</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   The control information written to the micro:bit.

when Microbit_Io_Pin1 WrotePWMControl PWM_Control_Field do

  • WrotePinADConfiguration – The WrotePinADConfiguration event is run after a successful write to the micro:bit’s configuration server for analog and digital pins. Pin\_AD\_Config\_Value will be the list of bytes that were written as part of the last call to the service.

Parameters:

 * <code>Pin\_AD\_Config\_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   A list of 8-bit values that are composed into a 19-bit mask, one bit per pin on the micro:bit.

when Microbit_Io_Pin1 WrotePinADConfiguration Pin_AD_Config_Value do

  • WrotePinData – The WrotePinData event will be run after the micro:bit’s output pins are successfully written by a call to the WritePinData method.

Parameters:

 * <code>IO\_Pin\_Data</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#makealist">_list_</a>) &mdash; A list of up to 19 values from 0-255 that were written to the micro:bit's
   pins from the last call to <a href="#WritePinData"><code>WritePinData</code></a>.

when Microbit_Io_Pin1 WrotePinData IO_Pin_Data do

  • WrotePinIOConfiguration – The WrotePinIOConfiguration event will run after a successful update of the micro:bit’s input/output pin configuration. Pin\_IO\_Config\_Value that was sent to the device will be passed as a parameter to the event.

Parameters:

 * <code>Pin\_IO\_Config\_Value</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/lists.html#emptylist">_list_</a>) &mdash;
   A list of 8-bit values that are composed into a 19-bit mask, one bit per pin on the micro:bit.

when Microbit_Io_Pin1 WrotePinIOConfiguration Pin_IO_Config_Value do