Show Posts
Pages: [1]
1  Topics / Device Hacking / Arduino ADK needs to be interpreted as USB keyboard for Android Tablet on: March 04, 2012, 10:39:30 pm
So far, here is the ADK program. Originally it was a simple debounce program that turned LEDs on/off. At the moment it issues a Serial.write command when a given button is pressed. It is worth pointing out one of the buttons is a N.O. SPST switch while the other is a N.C. SPST switch and thus, the program is written to accommodate this feature (which I cannot change).

Code:
/* Arduino ADK run-time program
 * Author:    omitted
 * Last Mod:  3/2/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 1;   // will become TX2, currently PL0
 const int outPinR    = 1;   // currently PL1
 
 int debounce   = 20;   // number of ms to wait for debounce
 
 int readStatusL;
 int readStatusR;
 
 
 void setup()
 {
     Serial.begin(115200);
     delay(2000);// Give reader a chance to see the output
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     //pinMode(outPinL, OUTPUT);
     //pinMode(outPinR, OUTPUT);
     delay(2000);
 }
 
 void loop()
 {  
     //Serial.println(1);
     readStatusL  = digitalRead(pedalL);
    
     if (readStatusL == LOW)
     {
         delay(debounce);
         if (readStatusL == LOW)
         {
             //digitalWrite(outPinL, HIGH);
             Serial.write(0x13);
             //Serial.println(2);
         }
         else
         {
             //digitalWrite(outPinL, LOW);
             //Serial.println(3);
         }
     }
    
     if (readStatusL == HIGH)
         //digitalWrite(outPinL, LOW);
    
     readStatusR  = digitalRead(pedalR);
    
     if (readStatusR == HIGH)
     {
         delay(debounce);
         if (readStatusR == HIGH)
         {
             //digitalWrite(outPinR, HIGH);
             Serial.write(0x14);
             //Serial.println(4);
         }
         else
         {
             //digitalWrite(outPinR, LOW);
             //Serial.println(5);
         }
     }
    
     if (readStatusR == LOW)
     {
         //digitalWrite(outPinR, LOW);
     }
 }

Ok so it is my understanding that issuing a Serial.write command will write the data (hopefully in hex) to the transmission port (pin 1) and if I recall correctly this is linked directly into the USB shield on the ADK board. So my problems complicate because I want to connect the ADK via USB to an Android Tablet (currently running Honeycomb) and get the tablet to recognize the ADK as a keyboard input. The purpose behind this is I have written an android app that uses the up and down arrows on the keyboard (KEYCODE_DPAD_DOWN and KEYCODE_DPAD_UP are the Android scancodes which translate to 0x0014 and 0x0013 in hex). This works with a normal USB keyboard and also with a Bluetooth pedal (PageFlip Cicada) that issues the up and down arrow key commands.

Now as it stands, here is what I have read about trying to implement this feature.
http://source.android.com/tech/input/keyboard-devices.html  Talks about keyboard devices in general
http://developer.android.com/guide/topics/usb/adk.html   Talks about Using Android Open Accessory Dev. Kit

So in short I am a little stuck. If you need more information please post your specific questions and as always feedback is appreciated.
2  Using Arduino / Project Guidance / Re: Mega ADK not performing correctly on: February 10, 2012, 07:46:24 pm
SOLVED:

New code
Code:
/* Arduino ADK run-time program
 * Author:    *omitted*
 * Last Mod:  2/10/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 18;   // will become TX2, currently PL0
 const int outPinR    = 19;   // currently PL1
 
 int debounce   = 20;   // number of ms to wait for debounce
 
 int readStatusL;
 int readStatusR;
 
 
 void setup()
 {
     Serial.begin(9600);
     Serial.println("Hello world");
     delay(2000);// Give reader a chance to see the output
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     pinMode(outPinL, OUTPUT);
     pinMode(outPinR, OUTPUT);
     delay(2000);
//     digitalWrite(outPinL, LOW);    // LED off
//     digitalWrite(outPinR, LOW);
 }
 
 void loop()
 { 
     Serial.println(1);
     readStatusL  = digitalRead(pedalL);
     
     if (readStatusL == LOW)
     {
         delay(debounce);
         if (readStatusL == LOW)
         {
             digitalWrite(outPinL, HIGH);
             Serial.println(2);
         }
         else
         {
             digitalWrite(outPinL, LOW);
             Serial.println(3);
         }
     }
     
     if (readStatusL == HIGH)
         digitalWrite(outPinL, LOW);
     
     readStatusR  = digitalRead(pedalR);
     
     if (readStatusR == LOW)
     {
         delay(debounce);
         if (readStatusR == LOW)
         {
             digitalWrite(outPinR, HIGH);
             Serial.println(4);
         }
         else
         {
             digitalWrite(outPinR, LOW);
             Serial.println(5);
         }
     }
     
     if (readStatusR == HIGH)
         digitalWrite(outPinR, LOW);
 }

After doing more reading about setting the internal pull-up resistance on inputs, I was not reading carefully enough when it said it also sets the input to HIGH unless it is pulled down by an input (grounded). So I modified the code to trigger on LOW and redid the buttons so instead they connected the input through 10k to ground if the button was pressed and it works now.
3  Using Arduino / Project Guidance / Re: Mega ADK not performing correctly on: February 10, 2012, 06:35:44 pm
Code:
/* Arduino ADK run-time program
 * Author:    *omitted*
 * Last Mod:  2/10/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 18;   // will become TX2, currently PL0
 const int outPinR    = 19;   // currently PL1
 
 int debounce   = 20;   // number of ms to wait for debounce
 
 int readStatusL;
 int readStatusR;
 
 
 void setup()
 {
     Serial.begin(9600);
     Serial.println("Hello world");
     delay(2000);                        //verify on serial monitor
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     pinMode(outPinL, OUTPUT);
     pinMode(outPinR, OUTPUT);
 }
 
 void loop()
 { 
     Serial.println(1);
     readStatusL  = digitalRead(pedalL);
     
     if (readStatusL == HIGH)
     {
         delay(debounce);
         if (readStatusL == HIGH)
         {
             digitalWrite(outPinL, HIGH);
             Serial.println(2);
         }
         else
         {
             digitalWrite(outPinL, LOW);
             Serial.println(3);
         }
     }
     
     readStatusR  = digitalRead(pedalR);
     
     if (readStatusR == HIGH)
     {
         delay(debounce);
         if (readStatusR == HIGH)
         {
             digitalWrite(outPinR, HIGH);
             Serial.println(4);
         }
         else
         {
             digitalWrite(outPinR, LOW);
             Serial.println(5);
         }
     }
 }

Newer code with debug statements
4  Using Arduino / Project Guidance / Re: Mega ADK not performing correctly on: February 10, 2012, 06:33:18 pm
I changed the supply voltage and voltage of the circuit to 5v but it is still showing weird behavior. however, I do have more information. First of all, I need to write HIGH to both inputs to turn on the internal pull-up resistors so I have a high impedance on my input. I have tested with and without this code and it still does not do what is intended. With the code it always sees the inputs as high but does not light the LEDs until one of the buttons is pressed then both LEDs are lit. I could not this "data sheet" you speak of, and where it says this is a bad idea. Anyways, without the code it performs the same. The questions I cannot answer are 1. Why do both LEDs turn on when the button is pressed and 2. Is there a better way to actively debug this other than using Serial.println statements and following the serial monitor output?

In the future, if you are referencing a data sheet could you please link it? I know the arduino website has info about the board, but afaik no formal data sheet, only a schematic and info about the board on a web page. I am used to seeing formal specifications in a document.
5  Using Arduino / Project Guidance / Re: Mega ADK not performing correctly on: February 06, 2012, 06:34:30 pm
The power source is 10v, but it should be feeding ~9v. I have already made the consideration of stepping down the voltage since it is a digital input after all.

I will use the debugger in the IDE as you suggested I should.

The program should be looking at the two inputs from the switches, debouncing the inputs then switching on the corresponding LED for each press. Currently the program is taking in the inputs, but will (seemingly) turn on both LEDs. I feel like this can be resolved as either a hardware issue or program one if I looked at the program behavior in the debugger
6  Using Arduino / Project Guidance / Re: Mega ADK not performing correctly on: February 06, 2012, 03:57:26 pm
bumping
7  Using Arduino / Project Guidance / Mega ADK not performing correctly (SOLVED) on: February 03, 2012, 06:04:44 pm
For starters, the program (no compile errors)
Code:
/* Arduino ADK run-time program
 * Author:    -omitted-
 * Last Mod:  1/30/12
 *
 */
 
 const int pedalL     = 6;    // pin PE4, left pedal
 const int pedalR     = 7;    // pin PE5, right pedal
 
 const int outPinL    = 35;   // will become TX2, currently PL0
 const int outPinR    = 36;   // currently PL1
 
 int debounce   = 40;   // number of ms to wait for debounce
 
 int readStatusL = LOW;  // Triggers on LOW
 int readStatusR = LOW;  // Triggers on LOW
 
 
 void setup()
 {
     pinMode(pedalL, INPUT);
     digitalWrite(pedalL, HIGH);    // Rpu on
     pinMode(pedalR, INPUT);
     digitalWrite(pedalR, HIGH);    // Rpu on
     pinMode(outPinL, OUTPUT);
     pinMode(outPinR, OUTPUT);
     digitalWrite(outPinL, LOW);    // LED off
     digitalWrite(outPinR, LOW);
 }
 
 void loop()
 {  
     readStatusL  = digitalRead(pedalL);
    
     if (readStatusL == HIGH)
     {
         delay(debounce);
         if (readStatusL == HIGH)
         {
             digitalWrite(outPinL, HIGH);
         }
         else
         {
             digitalWrite(outPinL, LOW);
         }
     }
    
     readStatusR  = digitalRead(pedalR);
    
     if (readStatusR == HIGH)
     {
         delay(debounce);
         if (readStatusR == HIGH)
         {
             digitalWrite(outPinR, HIGH);
         }
         else
         {
             digitalWrite(outPinR, LOW);
         }
     }
 }

Now the details of the circuit.


Above is the input from a transcription pedal. However since the pedal has not been fully cannibalized, I have replaced the normal switches with N.O. SPST switches. Now the way it is currently programmed, the R port in the above picture goes to the digital Port 3 (Pin 7) on the board while L goes to digital pin 2 (Pin 6) on the board. I have two LEDs connected to digital ports 48 and 49 (Pins 36 and 35), which terminate to ground. I should also mention the board is being powered via USB and the circuit shown above is on a bread board being powered with 10v. Now here is where things have been weird. Pressing either button turns on both LEDs (dimly). Now here is where it gets weirder. When using the ground on the breadboard as a reference, I see both outputs with a voltage of 1.6v while the input voltage is ~7.7v on the input of the pressed side, but it shows 1.6v on the other input (the side that the button is not pressed on). Even stranger is when I use Gnd from the board as the reference voltage. I see the ground on the bread board as .35v when nothing is pressed and -2v when a button is pressed. If you need more information please ask for it.

The ideal behavior is when the left button is pressed then the LED in digital port 49 (pin 35) lights up and when the right button is pressed then the LED in digital port 48 (pin 36) lights up. Currently the LEDs directly terminate to ground on the bread board. A quick reply would be appreciated
8  Using Arduino / Programming Questions / Configuring IO pins/ports on: November 28, 2011, 10:40:14 pm
I am attempting to set up communication between a ADK board and BT board by connecting an 8-bit data bus between the boards to communicate in parallel. What are the semantics or syntax for sending, say, a number or a byte of data through this 8-bit connection?
9  Using Arduino / Microcontrollers / Re: Interfacing BT and ADK boards on: November 21, 2011, 08:59:55 pm
As an after thought I was curious if I could just take the serial Tx output on the ADK and just picking an I/O pin on the BT and just immediately outputting the data to the pin connected to the Bluetooth module
10  Using Arduino / Microcontrollers / Interfacing BT and ADK boards on: November 21, 2011, 08:13:14 pm
Hi, I am using two boards from Arduino, the BT and Mega ADK, to process some inputs on the ADK and output via bluetooth through the BT board. I want to transmit from one Tx pin on the Mega ADK to an input pin on the BT board. What I am asking is what pin on the BT would need this Tx input and I am missing anything in terms of communication between the two boards.
11  Using Arduino / Networking, Protocols, and Devices / Re: Arduino Mega ADK and bluetooth on: November 14, 2011, 09:01:08 pm
Also I saw this one, but I am unsure if it is what I need. I know Arduino has their BT board, but I don't know if that is perfect or overkill?
12  Using Arduino / Networking, Protocols, and Devices / Arduino Mega ADK and bluetooth on: November 14, 2011, 08:00:56 pm
Hello

Currently I am looking to implement some peripheral functionality with an Android tablet using the Mega ADK board. However it would be nice to interface via Bluetooth rather than wired. So I was curious about a couple of things. First of all, all I am doing is outputting commands from the Mega ADK through the serial output. I was planning on then transmitting it through a bluetooth module to be received at the other end by the tablet. Also, I was thinking about buying this module for bluetooth interfacing http://www.sparkfun.com/products/158 with the tablet. So I was wondering if anyone had recommendations about my setup or some suggested hardware to try
Pages: [1]