Skip to content

Commit af97682

Browse files
authored
Set battery level example added
1 parent ad3d994 commit af97682

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This example shows how to set the battery level to be reported to the host OS
3+
*
4+
* It reduces the power by 1% every 30 seconds
5+
*
6+
*/
7+
8+
#include <Arduino.h>
9+
#include <BleGamepad.h>
10+
11+
BleGamepad bleGamepad;
12+
13+
int batteryLevel = 100;
14+
15+
void setup()
16+
{
17+
Serial.begin(115200);
18+
Serial.println("Starting BLE work!");
19+
bleGamepad.begin();
20+
}
21+
22+
void loop()
23+
{
24+
if (bleGamepad.isConnected())
25+
{
26+
Serial.print("Battery Level Set To: ");
27+
Serial.println(batteryLevel);
28+
bleGamepad.setBatteryLevel(batteryLevel);
29+
delay(30000);
30+
}
31+
}

0 commit comments

Comments
 (0)