Arduino101 按钮

« 返回首页

Arduino101 按钮

Arduino101 按钮组件允许用户监听连接到 Arduino 数字引脚的按钮触发的事件。该扩展程序会响应指定数字引脚上的电压变化,因此可用于响应任何根据外部现象(例如运动检测器)发出高/低信号的硬件组件。

更多链接:<ul><li>下载 Arduino 101 按钮的示例项目。</li><li>查看 Arduino 101 按钮的操作说明。</li></ul>

属性

  • BluetoothDevice – The BluetoothLE component with a connection to the Arduino 101.

get Arduino101Button1 BluetoothDevice

set Arduino101Button1 BluetoothDevice  to

  • Pin – The Pin on the Arduino board that the device is wired in to.

get Arduino101Button1 Pin

set Arduino101Button1 Pin  to

方法

  • IsSupported – Tests whether the Bluetooth low energy device is broadcasting support for the service. If true, calls to TurnOn and TurnOff should work correctly. Otherwise an error will be reported through the Screen’s ErrorOccurred event.

call Arduino101Button1 IsSupported

  • ReadButtonState – Read the current state of the button as reported by the Arduino. On success, the ButtonStateReceived event will be run. If the state of the button has changed, the Pressed or Released events will be run as well.

call Arduino101Button1 ReadButtonState

  • RequestButtonStateUpdates – Request notifications from the Arduino for changes in the button state. The ButtonStateReceived event will be run after every sample is received, even if no change occurs. If a change in the state occurs, either the Pressed or the Released event will be run.

call Arduino101Button1 RequestButtonStateUpdates

  • StopButtonStateUpdates – Stop listening for notifications of button states from the Arduino. This only has an effect if there was a previous call to RequestButtonStateUpdates. There may be additional pending messages that will be processed after this call, so if accuracy in the data delivery are important an additional variable should be used to track the state of event processing.

call Arduino101Button1 StopButtonStateUpdates

事件

  • ButtonStateReceived – The ButtonStateReceived event is run when any button state is received by the Bluetooth low energy component from the Arduino. This state value may be the same for extended periods of time if the button switch is left in an open or closed state.

Parameter:

 * <code>Button_State</code> (<a href="http://appinventor.mit.edu/explore/ai2/support/blocks/math.html#number">_number_</a>) &mdash; The button state: 0 if released, 1 if pressed.

when Arduino101Button1 ButtonStateReceived Button_State do

  • Pressed – The Pressed event is run when a button state is observed to go from a low signal to a high signal, indicating that the button switch has been pressed and the circuit is closed.

when Arduino101Button1 Presseddo

  • Released – The Released event is run when a button state is observed to go from a high signal to a low signal, indicating that the button switch has been released and the circuit is open.

when Arduino101Button1 Releaseddo

文档反馈