Android Tutorial How to connect to your Arduino using B4A

I recently purchased an Arduino USBDroid. The spiel told me I could connect it to my Android phone, but that was about it! I eventually worked it out after a week or so, and a bit of luck :) and thought I would share my findings and document how to connect your Arduino to your Android phone with the help of Basic for Android. I hope someone finds it useful/helpful.
p.s. I had to zip file has the PDF in it :)

Jeremy
 

Attachments

  • Connecting your Arduino board to an Android Phone.zip
    258.8 KB · Views: 1,468

drowles

Member
Licensed User
Longtime User
Just Curious...

I've seen some online pictures of Arduino, but rather unclear on what can actually be done with it... If it's not too personal, what did you plan to build with it?
 

jscoulter

Member
Licensed User
Longtime User
Hi. That information is in the document :) I am monitoring voltage and temperature, both analog, for my son's science project.
I have also just been looking at how to output video data via a composite lead and a couple of resisters...and some programming :)
To be honest, its almost limitless as to what it can do. I find new things every day it seems :) Yeah, the programming is very c like, but thats ok if you dont know it, as most of the experiments have code.I am lucky as i know C and C++ ok-ish and I know whats going on.


Jeremy
 

diego

Member
Licensed User
Longtime User
Hi jscoulter, I tried to compile Demo example as described in the manual (needed to change "wiring.h" with "wire.h"), and now I get a lot of errors:

B4X:
In file included from C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/Adb.h:21,
                 from C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:18:
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/usb.h:193: error: 'boolean' has not been declared
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/usb.h:211: error: 'boolean' has not been declared
In file included from C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:18:
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/Adb.h:107: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/Adb.h:124: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/Adb.h:130: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/Adb.h:137: error: 'boolean' has not been declared
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb/Adb.h:141: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:26: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static void ADB::init()':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:42: error: 'connected' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: At global scope:
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:94: error: 'boolean' has not been declared
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static Connection* ADB::addConnection(const char*, int, void (*)(Connection*, adb_eventType, uint16_t, uint8_t*))':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:98: error: 'malloc' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:106: error: 'free' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:114: error: 'class Connection' has no member named 'reconnect'
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: At global scope:
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:250: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static void ADB::openClosedConnections()':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:290: error: 'millis' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static void ADB::handleClose(Connection*)':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:342: error: 'class Connection' has no member named 'reconnect'
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static void ADB::handleConnect(adb_message*)':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:425: error: 'connected' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static void ADB::poll()':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:447: error: 'connected' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:450: error: 'delay' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:454: error: 'connected' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:458: error: 'pollMessage' is not a member of 'ADB'
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: At global scope:
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:493: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:514: error: 'boolean' does not name a type
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In function 'void usbEventHandler(usb_device*, usb_eventType)':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:620: error: 'isAdbDevice' is not a member of 'ADB'
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:635: error: 'connected' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static int ADB::write(Connection*, uint16_t, uint8_t*)':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:659: error: 'connected' was not declared in this scope
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp: In static member function 'static int ADB::writeString(Connection*, char*)':
C:\Users\Diego\Documents\Arduino\arduino-1.0.1\libraries\Adb\Adb.cpp:685: error: 'connected' was not declared in this scope

what am I doing wrong?
 

PaulR

Active Member
Licensed User
Longtime User
The errors you are getting are because a couple of files in the the library do not include arduino.h. The wiring.h error is fixed by changing it to <wiring.h> so the compiler searches the includes directories.

I have uploaded version of the library with these small fixes already done.
 

Attachments

  • Adb.zip
    26.1 KB · Views: 521
Top