Lesson 14: Retrieving Text Input from Smartphone


Written by Jonathan Sim

You can find this lesson and more in the Arduino IDE (File -> Examples -> Andee). If you are unable to find them, you will need to install the Andee Library for Arduino IDE.

Works on iOS and Android
In this lesson, I'll show you how to create a text input button to retrieve user-input text from their smartphones!


When the text input button is pressed, the Andee app will display a keyboard to the user requesting input. As a developer, you have the option of choosing what kind of keyboard you'd like to show.

Here are keyboard layouts you can choose:

  • ALPHA_NUMERIC - Alpha-numeric keyboard.
  • ALPHA_NUMERIC_PW - Alpha-numeric keyboard, input as password.
  • NUMERIC - Numeric keyboard.
  • NUMERIC_PW - Numeric keyboard, input as password.


Top of the Code

#include <SPI.h>
#include <Andee.h>

// We'll create a text input button and a display box to display
// the user input
AndeeHelper displaybox;
AndeeHelper textInputButton;
char userInput[32];


void setup()
  Andee.begin();  // Setup communication between Annikken Andee and Arduino
  Andee.clear();  // Clear the screen of any previous displays
  setInitialData(); // Define object types and their appearance


void setInitialData()
  displaybox.setTitle("Here's what you wrote");
  textInputButton.setType(KEYBOARD_IN); // Sets object as a text input button
  textInputButton.setTitle("Type something!");
  // Sets the type of keyboard to show to the user


void loop()
  if( textInputButton.isPressed() )
    memset(userInput, 0x00, 32); // Empty the contents of the string before receiving user input
    textInputButton.ack(); // Acknowledge button press or else phone will be left waiting
    textInputButton.getKeyboardMessage(userInput); // Display keyboard and store input into userInput
    displaybox.setData(userInput); // Display user input on the display box
  displaybox.update(); // Always remember to update so that new content will be displayed
  delay(500); // Always leave a short delay for Bluetooth communication
comments powered by Disqus