Lesson 34: Using Andee IO pins as OUTPUT pins


by Hasif Amran <hasif@annikken.com>

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

Using Andee IO pins as OUTPUT pins!

// In this lesson, There are Red LEDs on AIO Pins 1,3,5,7 and Green LEDs on AIO Pins 0,2,4,6


Top of the Code

Always include these libraries. Annikken Andee needs them to work with the Arduino!

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

// Every object that appears on your smartphone's screen
// needs to be declared like this:
AndeeHelper redButton;
AndeeHelper greenButton;


The setup() function is meant to tell Arduino what to do only when it starts up.

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
  for (int i = 0; i<8; i++)
  }//Set pins 0 to 7 to OUTPUT


This is the function meant to define the types and the appearance of all the objects on your smartphone

void setInitialData()
  //// Let's draw the first object! //////////////////////////////////////////

  redButton.setId(0);  // Each object must have a unique ID number
  redButton.setType(BUTTON_IN);  // This defines your object as a button input box
  redButton.setLocation(0, 0, FULL); // Sets the location and size of your object  
  redButton.setTitle("RED ON");//Sets the text on this button
  //// Let's draw the second object! ////////////////////////////////////////
  greenButton.setId(1); // Don't forget to give it a unique ID number
  greenButton.setType(BUTTON_IN); // Another button input box
  greenButton.setLocation(1,0,FULL); // Second row, left-most, full size
  greenButton.setTitle("GREEN ON");//Sets the text on this button  
IMG 7753.JPG


Arduino will run instructions here repeatedly until you power it off.

void loop()
  //Here is how you code a toggle state button:
    // Prevents a repeated button press. Button will not be available until Arduino
    // replies the smartphone with an acknowledgement message.
    if (redState == 0)// If the state of the Red LED is LOW
      redState = 1;//Change the state of Red LED to HIGH
      Andee.AIO_digitalWrite(1,HIGH);//OUTPUT HIGH on AIO Pin 1
      Andee.AIO_digitalWrite(3,HIGH);//OUTPUT HIGH on AIO Pin 3
      Andee.AIO_digitalWrite(5,HIGH);//OUTPUT HIGH on AIO Pin 5
      Andee.AIO_digitalWrite(7,HIGH);//OUTPUT HIGH on AIO Pin 7
      redButton.setTitle("RED OFF");//Change the text on the button to RED OFF
      redButton.update();//Update the UI to refresh its appearance on the smart device

    else if (redState == 1)//If the state of the Red LED is HIGH
      redState = 0;//Change the state of Red LED to LOW
      redButton.setTitle("RED ON");//Change the text on the button to RED ON
      Andee.AIO_digitalWrite(1,LOW);//OUTPUT LOW on AIO Pin 1
      Andee.AIO_digitalWrite(3,LOW);//OUTPUT LOW on AIO Pin 3
      Andee.AIO_digitalWrite(5,LOW);//OUTPUT LOW on AIO Pin 5
      Andee.AIO_digitalWrite(7,LOW);//OUTPUT LOW on AIO Pin 7
      redButton.update();//Update the UI to refresh its appearance on the smart device
//Do the same for the Green LED
    if (greenState == 0)
      greenState = 1;
      greenButton.setTitle("GREEN OFF");

    else if (greenState == 1)
      greenState = 0;
      greenButton.setTitle("GREEN ON");

  greenButton.update(); // Call update() to refresh the display on your screen
  redButton.update(); // If you forgot to call update(), your object won't appear
  delay(100);// A short delay is necessary to give Andee time to communicate with the smartphone

comments powered by Disqus