thnx,
I've been testing a lot, and i've found a nice tutorial. now i still have some questions.
code from android:
private static final byte COMMAND_TEXT = 0xF;
private static final byte TARGET_DEFAULT = 0xf;
private TextView textView;
private TextView textV;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mUsbManager = UsbManager.getInstance(this);
mPermissionIntent = PendingIntent.getBroadcast(this, 0, new Intent(
ACTION_USB_PERMISSION), 0);
IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
filter.addAction(UsbManager.ACTION_USB_ACCESSORY_DETACHED);
registerReceiver(mUsbReceiver, filter);
setContentView(R.layout.main);
textView = (TextView) findViewById(R.id.textView);
textView = (TextView) findViewById(R.id.textView1); // -->> this is the textview i like to add in my project
}
textView = (TextView) findViewById(R.id.textView1); // -->> this is the textview i like to add in my project
arduino "hello world sketch"
#include <Max3421e.h>
#include <Usb.h>
#include <AndroidAccessory.h>
#define ARRAY_SIZE 25
#define COMMAND_TEXT 0xF
#define TARGET_DEFAULT 0xF
#define COMMAND_TEXT 0xa
#define TARGET_DEFAULT 0xa
AndroidAccessory acc("Manufacturer", "Model", "Description",
"Version", "URI", "Serial");
char hello[ARRAY_SIZE] = {'H','e','l','l','o',' ',
'W','o','r','l','d',' ', 'f', 'r', 'o', 'm', ' ',
'A', 'r', 'd', 'u', 'i', 'n', 'o', '!'};
byte rcvmsg[255];
byte sntmsg[3 + ARRAY_SIZE];
void setup() {
Serial.begin(9600);
acc.begin();
}
void loop() {
if (acc.isConnected()) {
//read the sent text message into the byte array
//int len = acc.read(rcvmsg, sizeof(rcvmsg), 1);
//if (len > 0) {
if (rcvmsg[0] == COMMAND_TEXT) {
if (rcvmsg[1] == TARGET_DEFAULT){
//get the textLength from the checksum byte
byte textLength = rcvmsg[2];
int textEndIndex = 3 + textLength;
//print each character to the serial output
for(int x = 3; x < textEndIndex; x++) {
Serial.print((char)rcvmsg[x]);
delay(250);
}
Serial.println();
delay(250);
}
}
}
sntmsg[0] = COMMAND_TEXT;
sntmsg[1] = TARGET_DEFAULT;
sntmsg[2] = ARRAY_SIZE;
for(int x = 0; x < ARRAY_SIZE; x++) {
54;
sntmsg[3 + x] = hello[x];
}
acc.write(sntmsg, 3 + ARRAY_SIZE);
delay(250);
}
//}
how do i do this?
I've added the textview on my android app.
how do i send a second string from my android to the correct textview in android?
Thanks,
Chris