Connecting Arduino and Android Bluetooth -



Connecting Arduino and Android Bluetooth -

i tried connect arduino , android via bluetooth , it's working pretty good. while initialising connection wrote setup in arduino don't know how phone call it.

void setup() { // set setup code here, run once: genotronex.begin(9600); genotronex.println("bluetooth on please press 1 or 0 blink led .."); pinmode(ledpin,output); }

here code in android

void beginlistenfordata() { final handler handler = new handler(); final byte delimiter = 10; //this ascii code newline character stopworker = false; readbufferposition = 0; readbuffer = new byte[1024]; workerthread = new thread(new runnable() { public void run() { while(!thread.currentthread().isinterrupted() && !stopworker) { seek { int bytesavailable = mminputstream.available(); if(bytesavailable > 0) { byte[] packetbytes = new byte[bytesavailable]; mminputstream.read(packetbytes); for(int i=0;i<bytesavailable;i++) { byte b = packetbytes[i]; if(b == delimiter) { byte[] encodedbytes = new byte[readbufferposition]; system.arraycopy(readbuffer, 0, encodedbytes, 0, encodedbytes.length); final string info = new string(encodedbytes, "us-ascii"); readbufferposition = 0; handler.post(new runnable() { public void run() { mylabel.settext(data); } }); } else { readbuffer[readbufferposition++] = b; } } } } grab (ioexception ex) { stopworker = true; } } } }); workerthread.start(); }

help me out here. want when open connection android should show bluetooth on please press 1 or 0 blink led.. how listener in android if have timer set up.

if sure u have problem in setup function check construction genotronex whether errorfree. check using device varying baud rates 57600,115200.

android bluetooth arduino android-bluetooth arduino-uno

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -