Seeeduino ADK Main Board

The Android 3.1 platform (also backported to Android 2.3.4) introduces Android Open Accessory support, which allows external USB hardware (an Android USB accessory) to interact with an Android-powered device in a special "accessory" mode. Based on the Google’s ADK reference design, we merged advantages of Seeeduino into our Seeeduino ADK Main Board.
Now connect Seeeduino ADK Main Board to your Android mobile device and get started developing your custom accessory.

SKU:ARD52028P


Specifications

Interface


Seeeduino ADK Salient Features


Seeeduino ADK Hardware blocks are listed below:
A: Micro USB Socket, connect main board to PC. Used for uploading sketch using Arduino IDE.
B: Slide switch, to choose operating or I/O voltage: 3.3V or 5V
C: USB A Plug, connect to Android Mobile Device.
D: JST Conector / DC Jack, for external DC power supply. Do not connect PC while using external DC.
E: Reset Button, conveniently placed at the side to allow using reset while using shields.
F: I/O pins
G: ICSP,for programming Arduino Bootloader using AVR ICSP
H: breakouts pins of Max3421E GPIO
I: breakouts pins of FT232RL

Demonstration

The following image illustrates an application example of Seeeduino ADK Main Board with an Android Mobile. It runs the demo application based on MicroBridge provided illustrated this page. All basic electronic components are taken from Arduino Sidekick Basic Kit.


Seeeduino ADK Main Board and Android Mobile Connection



Using MicroBridge

The sample applications and library are available in the resources section. The following Arduino Sketch and Android code are commented well explaining the usage.

//Seeeduino ADK Demo using Niels Brouwers' MicroBridge library. 
//Connect a LED to D12 and a variable resistor(POT) to A0
 
#include <SPI.h>
#include <Adb.h>
 
// Adb connection.
Connection * connection;
 
// Elapsed time for ADC sampling. The rate at which ADC value is sent to Android device.
long lastTime;
 
//State of LED. Initially OFF. 
uint8_t LEDState=0;
 
// Event handler for the shell connection. 
// This event handler is called whenever data is sent from Android Device to Seeeduino ADK.
// Any data / command to be sent to I/O of ADK has to be handled here.
//
// For eg: 1.Controlling an ouput port 2.Interacting with a device connected
// to ADK via IIC or Serial Port.
 
void adbEventHandler(Connection * connection, adb_eventType event, uint16_t length, uint8_t * data)
{
 
  // In this example Data packets contain one byte and it decides the state of a LED connected to D12
  // The size of data is predetermined for this application. Android device also uses the same size.
 
  if (event == ADB_CONNECTION_RECEIVE)
  {
     if(LEDState != data[0])
     {
         digitalWrite(12, data[0]);   // Change the state of LED 
         Serial.println(data[0],DEC); 
       	 LEDState = data[0];          // Store the State of LED
     }	
  }
 
}
 
void setup()
{
  //Serial port debug purpose
  Serial.begin(57600);
 
  // Note start time
  lastTime = millis();
 
  // Set Digital pin 12 (LED is connected) as output
  pinMode(12,OUTPUT);
 
  // Initialise the ADB subsystem.  
  ADB::init();
 
  // Open an ADB stream to the phone's shell. Auto-reconnect. Use any unused port number eg:4568
  connection = ADB::addConnection("tcp:4568", true, adbEventHandler);  
 
}
 
void loop()
{
  //Check if ADC needs to be sampled.
  if ((millis() - lastTime) > 20)
  {
    //Read ADC value
    uint16_t data = analogRead(A0);
 
    //Send the ADC value to Android device as two bytes of data.
    connection->write(2,(uint8_t*)&data);
    lastTime = millis();
  }
 
  // Poll the ADB subsystem.
  ADB::poll();
}
/* Application demonstrates the interaction between Seeeduino ADK and Android Device
 * using Niels Brouwers' MicroBridge library. 
 * 
 * Android Device: Any device with Android v1.5 which supports ADB(Android Debug Bridge).   
 *  
 * This application uses a very simple (or a trivial) design to make it understandable.
 * 
 * Overview:
 * 1.Seeeduino ADK Main Board periodically samples Analog Channel 0 and sends it
 *   to Android Device for display. This value is displayed using a TextView and SeekBar Widgets
 * 
 * 2.Android device controls the state of a LED connected to Digital Pin 12 of ADK Main Board.
 *   A Button Widget used for this.
 * 
 * Microbridge uses ADB based client-server implementation. The Server code that runs on Android
 * device runs in a separate thread. Hence any update to UI widgets value has to be carried out 
 * in UI thread. This application uses XML based UI creation as it is easier for adding addition
 * UI Widgets. 
 * 
 */
package com.seeedstudio.SeeeduinoADKDemo;
 
import java.io.IOException;
 
import org.microbridge.server.AbstractServerListener;
import org.microbridge.server.Server;
 
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Button;
 
 
public class SeeeduinoADKDemo extends Activity implements OnClickListener {
	private int adcSensorValue=10;
 
	//UI Widgets
	TextView tvAdcvalue;
	SeekBar sbAdcValue;
	Button bOutPutLED;
 
	boolean LEDState = false ; //initially OFF
 
	// Create TCP server (based on  MicroBridge LightWeight Server). 
	// Note: This Server runs in a separate thread.
	Server server = null;
 
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.main);
 
		bOutPutLED = (Button) findViewById(R.id.buttonOuputLED);
		bOutPutLED.setOnClickListener(this); 
 
 
		// Create TCP server (based on  MicroBridge LightWeight Server)
		try
		{
			server = new Server(4568); //Use the same port number used in ADK Main Board firmware
			server.start();			
		} catch (IOException e)
		{
			Log.e("Seeeduino ADK", "Unable to start TCP server", e);
			System.exit(-1);
		}
 
		server.addListener(new AbstractServerListener() {
 
			@Override
			public void onReceive(org.microbridge.server.Client client, byte[] data)
			{
 
				if (data.length<2) return;
				adcSensorValue = (data[0] & 0xff) | ((data[1] & 0xff) << 8);
 
				//Any update to UI can not be carried out in a non UI thread like the one used
				//for Server. Hence runOnUIThread is used.
				runOnUiThread(new Runnable() {
					@Override
					public void run() {
						new UpdateData().execute(adcSensorValue);
 
					}
				});
 
			}
 
		});	 
 
	}	//End of TCP Server code 
 
	// UpdateData Asynchronously sends the value received from ADK Main Board. 
	// This is triggered by onReceive()
	class UpdateData extends AsyncTask<Integer, Integer, String> {
		// Called to initiate the background activity
		@Override
		protected String doInBackground(Integer... sensorValue) {
 
			//Init SeeekBar Widget to display ADC sensor value in SeekBar
			//Max value of SeekBar is set to 1024
			SeekBar sbAdcValue = (SeekBar) findViewById(R.id.sbADCValue);	    	
			sbAdcValue.setProgress(sensorValue[0]);    
			return (String.valueOf(sensorValue[0]));  //This goes to result
 
		}
 
		// Called when there's a status to be updated
		@Override
		protected void onProgressUpdate(Integer... values) {
			super.onProgressUpdate(values);
			// Not used in this case
		}
 
		// Called once the background activity has completed
		@Override
		protected void onPostExecute(String result) {
			//Init TextView Widget to display ADC sensor value in numeric. 
			TextView tvAdcvalue = (TextView) findViewById(R.id.tvADCValue);
			tvAdcvalue.setText(String.valueOf(result));
 
		}
	}
 
	//Called when the LED button is clicked
	@Override
	public void onClick(View v) {
		byte data; 
 
 
		// Toggle the state of LED
		if(LEDState == true)
		{
			LEDState = false;
			data = 0;
			bOutPutLED.setText("LED Off");
		}
		else
		{
			LEDState = true;
			data = 1;
			bOutPutLED.setText("LED On");
		}
 
		try
		{
			//Send the state of LED to ADK Main Board as a byte
			server.send(new byte[] {(byte) data});
		} catch (IOException e)
		{
			Log.e("Seeeduino ADK", "problem sending TCP message", e);
		}	
 
	}
 
}


Using Google ADK

Visit Android ADK Developer page for complete documentation on how to use Accessory API.

As Mega 2560

Seeeduino ADK Main Board can be used as Seeeduino Mega 2560. It also works well with GROVE System. The Grove - Base Shield can be used to connect the numerous Grove modules available.

And following is a demo showing 2.8%27%27 TFT Touch Shield working with Seeeduino ADK Main Board.

Output:

Resources

Copyright (c) 2008-2016 Seeed Development Limited (www.seeedstudio.com / www.seeed.cc)
This static html page was created from http://www.seeedstudio.com/wiki