Introduction
The Gamepad Controller Module is one of the input modules, using which user can give commands to the board using buttons and analog joystick present in different layouts:
- Digital Mode
- Joystick Mode
- Accelerometer Mode
You can toggle between the different modes using setting option present on the top right corner of the module.
Digital Mode
The digital mode is the default mode when the module opens. It has 10 digital buttons whose data is sent to the device when they are pressed or released.
- Up
- Down
- Left
- Right
- Triangle
- Cross
- Square
- Circle
- Select
- Start
Only the digital state of each button is sent to the device, whether it is pressed or not.
Joystick Mode
The joystick mode has both button and joystick in the layout.
The joystick is present on the left side of the layout. It sends 4 data to the device:
- X value: The value of the x position (on the horizontal axis) of the white dot in the joystick. It is an integer value and varies from -7 to 7. At the center, the value is 0.
- Y value: The value of the y position (on the verticle axis) of the white dot in the joystick. It is an integer value and varies from -7 to 7. At the center, the value is 0.
- Radial value: The distance from the center of the joystick. This value varies from 0 to 7. At the center, the value is 0 and on the perimeter of the joystick, the value is 7.
- Angle: The angle is the angle between the positive x-axis and the line joining the center and the current position of the dot. It varies from 0 to 360 at a step of 15 degrees.
The buttons work the same as the digital mode. Only 6 digital buttons are present in the joystick Mode:
- Triangle
- Cross
- Square
- Circle
- Select
- Start
Accelerometer Mode
The accelerometer mode is pretty the same as the analog mode, the only difference is that the joystick present in this mode is controlled with the accelerometer sensor present in the phone.
The values given to the hardware device is the same as the joystick: 4 analog values and 6 digital values.
Ensure that your child gets sufficient exposure to such futuristic technologies like AI with the help of hands-on experiences using AI kits for kids like Quarky. Sign up today to avail of special offers on this AI kit coming soon.
Arduino IDE Functions
Header
To include the GamePad module in the Arduino program, you have to include the following header:
#define CUSTOM_SETTINGS
#define INCLUDE_GAMEPAD_MODULE
After defining the above mention headers, you have to include the dabble library:
#include <Dabble.h>
You can download the zip of Arduino Library for
- evive, Uno, Mega, and Nano – Dabble-Arduino
- ESP32 – Dabble-ESP32
depending on the board you are using.
Enabling Bluetooth Communication
To enable Bluetooth communication, you have to initialize serial communication using the following code:
- For evive and Arduino Mega, Uno and Nano
Dabble.begin(Baud_Rate);
Here Baud_Rate is the baud rate set for the Bluetooth module. With evive, you normally get 115200 baud rate modules.
- For ESP32
Dabble.begin("Bluetooth_Name");
In place of Bluetooth_Name enter name that you want to keep for Bluetooth of ESP32. Default name given in the library is “MyEsp32”.
Refreshing the data
To refresh the data that the device has got from the mobile app, you have to use the following line of code:
Dabble.processInput();
Gamepad Functions
Following are the function available for the GamePad module:
Function | Return Type | Function Brief Decription | Returning Value |
---|---|---|---|
isUpPressed() | Boolean | The function tells whether the Up button is pressed or not. | 1 when Up button is pressed; 0 when Up button is not pressed. |
isDownPressed() | Boolean | The function tells whether the Down button is pressed or not. | 1 when Down button is pressed; 0 when Down button is not pressed. |
isLeftPressed() | Boolean | The function tells whether the Left button is pressed or not. | 1 when Left button is pressed; 0 when Left button is not pressed. |
isRightPressed() | Boolean | The function tells whether the Right button is pressed or not. | 1 when Right button is pressed; 0 when Right button is not pressed. |
isTrianglePressed() | Boolean | The function tells whether the Triangle button is pressed or not. | 1 when Triangle button is pressed; 0 when Triangle button is not pressed. |
isCirclePressed() | Boolean | The function tells whether the Circle button is pressed or not. | 1 when Circle button is pressed; 0 when Circle button is not pressed. |
isCrossPressed() | Boolean | The function tells whether the Cross button is pressed or not. | 1 when Cross button is pressed; 0 when Cross button is not pressed. |
isSquarePressed() | Boolean | The function tells whether the Square button is pressed or not. | 1 when Square button is pressed; 0 when Square button is not pressed. |
isStartPressed() | Boolean | The function tells whether the Start button is pressed or not. | 1 when Start button is pressed; 0 when Start button is not pressed. |
isSelectPressed() | Boolean | The function tells whether the Select button is pressed or not. | 1 when Select button is pressed; 0 when Select button is not pressed. |
getAngle() | Integer | This function returns the angle value between the x-axis and the line joining the dot and the center of the joystick. | The value varies form 0 to 360 degrees with a step of 15 degrees. |
getRadius() | Integer | The function returns the distance between the center of the joystick and the dot. | The value varies from 0 to 7. |
getXaxisData() | float | The fuction returns the x postion of the dot on the joystick. | The value varies from -7 to 7. |
getYaxisData() | float | The fuction returns the y postion of the dot on the joystick. | The value varies from -7 to 7. |
PictoBlox (Scratch) Blocks
Digital Mode
To use GamePad in digital mode, you will need a boolean block is () pressed on gamepad? block.
You just have to choose a button from the dropdown i.e Up, Down, Left, Right, Triangle, Circle, Cross, Square, Start or Select.

Joystick & Accelerometer Mode
To use GamePad as a regular Joystick, you have to use a reporter block “get () from Gamepad”.
In its drop-down, you will find 4 things i.e. X Value, Y Value, Angle and Radial Distance. Using these 4 values, you can develop a logic to control the left side of Gamepad and rest 6 digital controls will work similarly to digital mode.

Examples
In order to explain how to use the functions available for this module the data returned from this function is printed on Serial Monitor. Follow the steps given below:
- Copy code from below as per your board in Arduino IDE.
- Upload code
- Connect with Dabble via Bluetooth and open Gamepad
evive
Mega, Uno, and Nano
ESP32
Digital Mode
In this example, we are controlling a robot using the digital mode. The robot is the same as we build the one in this project: https://thestempedia.com/project/smartphone-controlled-mobile-robot.
Given below is the full script of the same:
You can download the PictoBlox program from here:
- evive: Smartphone Controlled Robot with Dabble
- Arduino Uno: Smartphone Controlled Robot with Dabble for Arduino Uno
In this example, we are displaying all the parameters on the evive Display
You can download the Scratch Program from here: Gamepad Module Analog value Display evive
Projects

This project will show you how to make an expressive and energetic humanoid bipedal robot.
- December 4, 2019 7:07 PM·

This project shows you how to make a Smartphone-controlled robot using ESP32.
- July 5, 2019 5:57 PM·

This project will show you how to make your own DIY hovercraft.
- June 7, 2019 7:30 PM·

This project will show you how to make a Smartphone-controlled stair-climbing robot.
- May 31, 2019 5:04 PM·

This project will show you how to make a DIY LED edge-lit acrylic sign.
- April 16, 2019 6:46 PM·

This project will show how to transform a simple strip of RGB LED into a stunning decorative light.
- March 12, 2019 5:31 PM·
This Post Has 2 Comments
Hello, does the gamepad IOS allow multi key press? For example Forward+Left
Right now, this is not possible in the iOS app, but this feature will be included soon, in the upcoming versions.