🤖
LinkIt 7697 BlocklyDuino 使用指南
  • LinkIt 7697 BlocklyDuino 使用指南
    • 認識 LinkIt 7697
    • 認識 BlocklyDuino
    • BlocklyDuino v2 & v3 比較
    • 安裝開發環境 (v2)
      • 安裝 Arduino 編輯器
      • 安裝驅動並連接開發板
      • 安裝 BlocklyDuino 編輯器
      • 連結兩個編輯器並上傳程式
    • 安裝開發環境 (v3)
    • BlocklyDuino 基礎操作
    • 實作範例教學
      • A01. 內建 LED 閃爍
      • A02. 外接 LED 閃爍
      • A03. 外接 LED 呼吸燈
      • A04. RGB LED 顏色變化
      • A05. 外部按鈕控制開關
      • A06. 蜂鳴器播放聲音
      • A07 .可變電阻控制電壓輸出
      • A08. 伺服馬達控制
      • A21. DHT: 溫濕度感應器
      • A22. HTU21D: 溫溼度感應器
      • A23. PMSX003: PM2.5 感測器
      • A24. HC-SR04P: 超音波測距
      • A25. ADXL345: 加速規(動態)
      • A26. ADXL345: 加速規(手勢)
      • A27. 1602/2004: 液晶顯示模組
      • A28. WS2812: RGB 彩色燈條
      • A29. MFRC522: RFID
      • B00. Grove 相關基礎知識
      • B01. Grove 光感應器
      • B02. Grove 超音波測距感應器
      • B03. Grove 溫溼度感應器
      • B04. Grove 繼電器
      • B05. Grove LED 燈條
      • B06. Grove OLED 顯示器
      • C01. 雲端控制 LED 開關
      • C02. 上傳溫溼度到雲端
      • D01. 手機透過 BLE 讀寫裝置資料
      • E01. 遙控器: 按鈕控制 LED
    • 資源鏈結
  • LinkIt 7697 - Arduino IDE 開發指南
    • 環境設定
      • 設定 Arduino IDE
      • 將 LinkIt 7697 連接到電腦
        • 在 Windows 上安裝 CP2102N 驅動程式
        • 在 macOS 上安裝 CP2102N 驅動程式
      • 執行第一個程式
    • 開發指南
      • GPIO
      • UART
      • ADC
      • EINT (外部中斷 / External Interrupt)
      • I2C
      • SPI
      • EEPROM
      • Timer
      • Flash (索引式儲存空間)
      • RTC (Real-Time Clock)
      • Software Serial
      • 使用 Wi-Fi 函式庫
      • 使用 MCS 函式庫
        • 連接到 MCS
        • 連接到 MCSLite
          • 建立可透過 MCS Lite 控制的 Beacon
        • MCS 函式庫 API 使用手冊
          • MCSDevice
          • MCSLiteDeviceMCSLiteDevice
          • MCSDataChannel 相關類別
      • 使用 BLE 低功耗藍牙
        • 藍牙信標
        • 主控裝置
        • 周邊裝置
        • 已知限制
        • LBLE API 指南
          • LBLE
          • LBLECentral
          • LBLEPeripheral
          • LBLEAdvertisementData
          • LBLEService
          • LBLECharacteristic
          • LBLEAddress
          • LBLEUuid
          • LBLEClient
      • 使用 LinkIt Remote
        • LRemote API
        • LRemote 控制元件 API
      • LinkIt 7697 腳位的初始狀態
      • LinkIt 7697 供電說明
      • 更新 Bootloader 與韌體
      • Flash 燒錄工具
      • FOTA 更新
      • LinkIt 7697 的功能限制
      • 自行編譯 Arduino Package
      • 回報問題
    • 週邊元件連接教學
      • SMD 按鈕
      • RGB 三色 LED
      • 可變電阻
      • 九軸感應器 (MPU-9250)
      • 溫度與濕度感應器 (AM2302)
      • 超音波距離感應器
      • 光感應器 (LM358)
      • 0.96 吋 OLED 顯示模組 (SSD1308Z)
      • 長條型 LED 顯示模組 (MY9221)
      • 繼電器
      • 伺服馬達 (EMAX 9g ES08A Servo)
      • 使用 74HC595 驅動七段顯示器
      • 使用 MAX7219 驅動七段顯示器
      • 使用 MAX7219 驅動 8x8 矩陣式顯示器
      • 使用 OLED 模組 (如 SH1106 / SSD1306... 等模組)
      • 使用 PCF8574 / PCF8574A 驅動 1602 LCD
    • 開發套件與擴充板
      • Grove Starter Kit
      • Robot Shield
        • OTTO97
    • 下載
    • 資源連結
    • BSP 版本更新資訊
  • LinkIt 7697 - Development Guide for Arduino IDE
    • Environment Setup
      • Setup Arduino IDE
      • Connecting LinkIt 7697 to Computer
        • Install CP2102N Driver on Windows
        • Install CP2102N Driver on macOS
      • Run Your First Sketch
    • Developer Guide
      • GPIO
      • UART
      • ADC
      • External Interrupt
      • I2C
      • SPI
      • EEPROM
      • Timer
      • Flash (Key-Pair Storage)
      • RTC (Real-Time Clock)
      • Software Serial
      • Using the Wi-Fi Library
      • Using MCS Library
        • Connecting to MCS
        • Connecting to MCSLite
          • Build a Beacon controlled by MCS Lite
        • MCS Library API Reference
          • MCSDevice
          • MCSLiteDevice
          • MCSDataChannel Classes
      • Using Bluetooth
        • Beacons
        • Central Devices
        • Peripheral Devices
        • Limitations of LBLE library
        • LBLE Library API Guide
          • LBLE
          • LBLECentral
          • LBLEPeripheral
          • LBLEAdvertisementData
          • LBLEService
          • LBLECharacteristic
          • LBLEAddress
          • LBLEUuid
          • LBLEClient
      • Using LinkIt Remote
        • LRemote
        • LRemote Control Classes
      • Initial Pin State of LinkIt 7697
      • Powering the LinkIt 7697
      • Update Bootloader and Firmware
      • Flash Uploading Tool
      • FOTA Update
      • Limitations of LinkIt 7697
      • Source Code of Arduino Package
      • Issue Report
    • Tutorial
      • SMD Buttons
      • RGB LED
      • Potentiometer
      • IMU 9DOF v2.0 (MPU-9250)
      • Temperature and Humidity Sensor Pro (AM2302)
      • Grove Ultrasonic Ranger
      • Light Sensor (LM358)
      • Grove OLED Display 0.96" (SSD1308Z)
      • LED Bar v2.0 (MY9221)
      • Relay
      • Mini Servo (EMAX 9g ES08A Servo)
      • Driving 7-segment Displays with 74HC595
      • Driving 7-segment Displays with MAX7219
      • Driving 8x8 Dot Matrices with MAX7219
      • Using OLED module (SH1106 / SSD1306... etc.)
      • Driving 1602 LCD with PCF8574 / PCF8574A
    • Kits and Shields
      • Grove Starter Kit
      • Robot Shield
        • OTTO97
    • Download
    • Resources
    • BSP Release Notes
Powered by GitBook
On this page
  • Example Sketch
  • Understanding the Example Sketch
  • Open Source Libraries
  1. LinkIt 7697 - Development Guide for Arduino IDE
  2. Developer Guide

Using LinkIt Remote

PreviousLBLEClientNextLRemote

Last updated 3 years ago

LinkIt Remote is a tool to easily create an iOS/Android remote UI for your LinkIt 7697 Arduino projects. It consists of two software:

  • The Arduino LRemote library for LinkIt 7697, which allows you to declare remote UI controls in your Arduino project.

  • The LinkIt Remote iOS/Android application, which allows you to scan and connect to nearby LinkIt 7697 devices running the LRemote library, and send commands to them.

The Arduino library and iOS/Android app communicates to each other through Bluetooth Low Energy.

Example Sketch

  1. To run the example, open Arduino IDE menu File > Examples > LRemote > RemoteControl example, and upload the sketch to LinkIt 7967.

  2. Keep LinkIt 7697 powered on

  3. Launch the LinkIt Remote app, and a "LinkIt 7" or "LinkIt 7697" device should appear in the device list.

Due to the limitation in BLE advertisement packet length, the device name may be truncated to "LinkIt 7". The device name will be fully displayed after connecting to it. iOS will cache the device name, so next time the app displays full device name. On an Android device, the device name is always truncated.

5.Tap on the LinkIt 7697 item, the app connects to LinkIt 7697 and display the following remote UI control:

6.Now tap the USR LED switch button, the onboard USR LED on the LinkIt 7697 should now light up.

7.Open the Arduino Serial Monitor, and drag the Value Slider. The Serial Monitor will print the new values you just dragged to.

That's it - you now have a remote control UI to your Arduino device.

Understanding the Example Sketch

The example we just demonstrated creates a BLE device named LinkIt 7697, and adds several GATT attributes that represents UI controls. The LinkIt Remote app parses these GATT attributes and displays the remote UI controls accordingly.

To use LRemote library, the first step is to configure the device. With LRemote library, you can simply set the device name, it's mobile UI orientation, and the layout grid size.

  // Setup the Remote Control's UI canvas
  LRemote.setName("LinkIt 7697");
  LRemote.setOrientation(RC_PORTRAIT);
  LRemote.setGrid(3, 5);

In the example above,

  • we configure a device named LinkIt 7697, and

  • assign the layout grid to be a 3 x 5 portrait grid. The grid is invisible on the Remote UI, and is used as a reference coordinate for control position and size, as shown below.

After setting the grid, we can start adding UI controls to the grid. For example, to create the USR LED button, first we declare a LRemoteSwitch in the global scope, as shown below:

#include <LRemote.h>
 
LRemoteSwitch switchButton;

and then we configure the text label, size, and position of the switch button:

void setup() {
  // Add an on/off switch
  switchButton.setText("USR LED");
  switchButton.setPos(0, 1);
  switchButton.setSize(1, 1);
  switchButton.setColor(RC_BLUE);
  LRemote.addControl(switchButton);
}
  • We set the text label as "USR LED"

  • The position parameter is (0, 1), which maps to the first column and second row, as shown below

  • and we set the color to RC_BLUE

  • finally, we call LRemote.addControl(switchButton) to add the switch to the remote control UI

You must declare the controls in global scope and then call LRemote.addControl in the setup() function. Otherwise the control will not appear correctly in the UI.

After setting up the controls, we call LRemote.begin() to start advertise our device.

  // Start broadcasting our remote contoller
  // This method implicitly initialized underlying BLE subsystem
  // to create a BLE peripheral, and then
  // start advertisement on it.
  LRemote.begin();

We can then use LRemote.connected() to check if the LinkIt Remote app has connected to our device:

  if(!LRemote.connected()) {
    Serial.println("waiting for connection");
    delay(1000);
  }

Once the LinkIt Remote app establishes the connection, it will retrieve our UI layout configuration, and display the switch button accordingly:

The app sends commands to LinkIt 7697 if the user made changes to the remote UI. To process these commands, we call LRemote.process() in the loop() function to periodically check for new commands:

void loop() {

  // Process the incoming BLE write request
  // and translate them to control events
  LRemote.process();
 
  // ...
}

Always call LRemote.process() before checking UI control values, e.g. isValueChanged() or getValue().

Once the commands are processed, the LRemote updates the values and state of each control. For a LRemoteSwitch, you can use

  • LRemoteSwitch::isValueChanged() to check if the user has made changes to the switch

  • LRemoteSwitch::getValue() to get the current value of the switch

    • 0 means the switch is off

    • 1 means the switch is on

The example code below turns on the USR LED once the user turns on the switch button in the app:

  if(switchButton.isValueChanged()){
    digitalWrite(LED_BUILTIN, switchButton.getValue());
  }

Sliders (LRemoteSlider) have the same set of APIs, except that getValue() returns the slider value instead.

Buttons(LRemoteButton and LRemoteCircleButton) have the same set of APIs, and

  • getValue() returns 0 when the button is not being pressed

  • getValue() returns 1 when the button is being pressed

You can also add LRemoteLabel that displays a one-line text. The user cannot interact with it, so it does not support the getValue() API.

Open Source Libraries

Following open source libraries are used in LRemote library and LinkIt Remote app:

  • JoystickView

  • Arduino Queue

  • virtual-joystick-android

Download and install LinkIt Remote from the store link below: