Skip to content

Commit 2f6e202

Browse files
authored
Merge pull request #11 from bcmi-labs/fix-Check_inputs
Clean-up and refactor `examples`/`Check_inputs`
2 parents e9dd014 + 7e24530 commit 2f6e202

File tree

2 files changed

+42
-30
lines changed

2 files changed

+42
-30
lines changed

examples/Check_inputs/Check_inputs.ino

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* This example allows the user to read the
2+
* inputs of the Braccio++ shield UI devices:
3+
* - joystick (up,down,left,right,select)
4+
* - button (enter)
5+
*/
6+
7+
#include <Braccio++.h>
8+
9+
String toMessage(int const input)
10+
{
11+
static String const message[] =
12+
{ "",
13+
"LEFT (Joystick)",
14+
"RIGHT (Joystick)",
15+
"SELECT (Joystick)",
16+
"UP (Joystick)",
17+
"DOWN (Joystick)",
18+
"ENTER (Button)"
19+
};
20+
21+
if (input < 7)
22+
return message[input];
23+
else
24+
return String("Error, invalid input value");
25+
}
26+
27+
void setup()
28+
{
29+
Serial.begin(115200);
30+
while(!Serial){}
31+
32+
Braccio.begin();
33+
Serial.println("Press any button or move the joystick.");
34+
}
35+
36+
void loop()
37+
{
38+
String const message = toMessage(Braccio.getKey());
39+
if(message != "")
40+
Serial.println(message);
41+
delay(100);
42+
}

0 commit comments

Comments
 (0)