Skip to content

Clean-up and refactor examples/Check_inputs #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions examples/Check_inputs/Check_inputs.ino

This file was deleted.

42 changes: 42 additions & 0 deletions examples/Tools/Check_Inputs/Check_Inputs.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* This example allows the user to read the
* inputs of the Braccio++ shield UI devices:
* - joystick (up,down,left,right,select)
* - button (enter)
*/

#include <Braccio++.h>

String toMessage(int const input)
{
static String const message[] =
{ "",
"LEFT (Joystick)",
"RIGHT (Joystick)",
"SELECT (Joystick)",
"UP (Joystick)",
"DOWN (Joystick)",
"ENTER (Button)"
};

if (input < 7)
return message[input];
else
return String("Error, invalid input value");
}

void setup()
{
Serial.begin(115200);
while(!Serial){}

Braccio.begin();
Serial.println("Press any button or move the joystick.");
}

void loop()
{
String const message = toMessage(Braccio.getKey());
if(message != "")
Serial.println(message);
delay(100);
}