This project shows an example of Bluetooth using Silicon Labs development kits and external sensors integrated with the BLE wireless stack. This project uses a Sparkfun Qwiic Joystick board and a UT-L 7-SEG R click board.
UT-L 7-SEG R click carries two SMD ultra-thin 7-segment LED displays and the MAX6969 constant-current LED driver from Maxim Integrated. It communicates with the target microcontroller over the SPI interface.
For more information about the MAX6969 constant-current LED driver, see the specification page.
The SparkFun Qwiic Joystick combines the convenience of the Qwiic connection system and an analog joystick that is similar to the analog joysticks on PS2 (PlayStation 2) controllers. Directional movements are simply measured with two 10 kΩ potentiometers, connected with a gimbal mechanism that separates the horizontal and vertical movements. This joystick also has a select button that is actuated when the joystick is pressed down. With the pre-installed firmware, the ATtiny85 acts as an intermediary (microcontroller) for the analog and digital inputs from the joystick. This allows the Qwiic Joystick to report its position over I2C.
For more information about the SparkFun Qwiic Joystick, see the specification page.
- 1x Bluetooth Low Energy Explorer Kit. For simplicity, Silicon Labs recommends the BGM220-EK4314A
- 1x SparkFun Qwiic Joystick Board
- 1x UT-S 7-SEG R click Board
- 1x smartphone running the 'Simplicity Connect' mobile app
Attach the UT-L 7-SEG R Click board to the Explorer kit. Make sure that the 45-degree corner of the NFC board matches the 45-degree white line of the Silicon Labs Explorer kit
The Sparkfun Qwiic Joystick board can be easily connected by using a Qwiic cable.
To test this application, you can either create a project based on an example project or start with a "Bluetooth - SoC Empty" project based on your hardware.
NOTE:
-
Make sure that the Third Party Hardware Drivers extension is installed as part of the SiSDK and the bluetooth_applications repository is added to Preferences > Simplicity Studio > External Repos.
-
SDK Extension must be enabled for the project to install the required components.
-
From the Launcher Home, add your hardware to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project filtering by "joystick_7seg".
-
Click Create button on the Bluetooth - Joystick 7seg example. Example project creation dialog pops up -> click Create and Finish and Project should be generated.
-
Build and flash this example to the board.
-
Create a Bluetooth - SoC Empty project for your hardware using Simplicity Studio 5.
-
Copy the file
src/app.c
into the project root folder (overwriting the existing file). -
Install the software components:
-
Open the .slcp file in the project.
-
Select the SOFTWARE COMPONENTS tab.
-
Install the following components for the device:
- [Services] → [IO Stream] → [IO Stream: USART] → default instance name: vcom
- [Application] → [Utility] → [Log]
- [Platform] → [Driver] → [Button] → [Simple Button] → default instance name: btn0
- [Platform] → [Driver] → [I2C] → [I2CSPM] → default instance name: qwiic
- [Third Party Hardware Drivers] → [Display & LED] → [MAX6969 - UT-M 7-SEG R Click (Mikroe)]
- [Third Party Hardware Drivers] → [Human Machine Interface] → [Qwiic Joystick (Sparkfun)]
-
-
Import the GATT configuration:
-
Build and flash this example to the board.
Note:
- A bootloader needs to be flashed to your board if the project starts from the "Bluetooth - SoC Empty" project, see Bootloader for more information.
The application reads a current joystick position every 100ms and prints it on the 7-segment LED display. For simplicity, reading is the current vertical position from joystick and only look at the MSB and get an 8-bit reading (for 256 positions). Each time the joystick moves up to the highest position (255), the joystick data will be increased by 1. On the contrary, each time the joystick moves down to the lowest position (0), the joystick data will be decreased by 1. When the Bluetooth connection is opened, the joystick data can be seen via Bluetooth by reading it manually or it can be also automatically updated using Notification.
Follow the below steps to test the example with the Simplicity Connect application:
-
Open the Simplicity Connect app on your smartphone and allow the permission requested the first time it is opened.
-
Find your device in the Bluetooth Browser, advertising as joystick_7seg, and tap Connect. Then you need accept the pairing request when connected for the first time.
-
Find the Unknown Service in the GATT database.
-
Try to read, write, re-read the characteristics, and check the value.
-
Enable Notification on this service. Try to move up/down the joystick then check the value on the 7-segment LED display and on the Simplicity Connect app.
-
Try to use the BTN0 button to turn on/off the 7-segment LED display at any time.
-
You can launch the Console that is integrated in Simplicity Studio or can use a third-party terminal tool like TeraTerm to receive the logs from the virtual COM port.