Arduino/Android Bluetooth project


hi,

we group of 3 students. year, our project connect android tablet , arduino bluetooth, equipped leds. have arduino mega 2540 "bluetooth shield v1.1 seeedstudio" , samsung galaxy tab 2. pairing between devices done, data transfer fails. aim send value 1 arduino when button "turn led 1 on" clicked on app developped ourselves. same idea leds 2 , 3.

so seems it's bluetooth program contains problem because original 1 without bluetooth function passed tests successfully.

here code :

#include <softwareserial.h>   //software serial port
#define rxd 7
#define txd 6
softwareserial bluetoothserial(7,6);  //(rxd, txd)
const int led0 = 0;
const int led1 = 1;
const int led2 = 2;
char seriala = 0;
void setup() {
  serial.begin(9600);
  pinmode(rxd, input);
  pinmode(txd, output);
  setupbluetoothconnection();
  pinmode(led0, output);
  pinmode(led1, output);
  pinmode(led2, output);
  digitalwrite(led0, low);
  digitalwrite(led1, low);
  digitalwrite(led2, low);
}
void loop() {
  char seriala;
    if(bluetoothserial.available()){//check if there's data sent remote bluetooth shield
      seriala = bluetoothserial.read();
      serial.print(seriala);
    }
    else{
digitalwrite(led0, high);
digitalwrite(led1, high);
digitalwrite(led2, high);
    }
  switch (seriala)
  {
      case 1:     
        digitalwrite(led0, high);     
      break;     
      case 2:     
        digitalwrite(led0, low);     
      break;     
      case 3:     
        digitalwrite(led1, high);     
      break;     
      case 4:     
        digitalwrite(led1, low);     
      break;     
      case 5:     
        digitalwrite(led2, high);     
      break;     
      case 6:     
        digitalwrite(led2, low);     
      break;                   
   }
   }
void setupbluetoothconnection()
{
  bluetoothserial.begin(38400); //set bluetoothbee baudrate default baud rate 38400
  bluetoothserial.print("\r\n+stwmod=0\r\n"); //set bluetooth work in slave mode
  bluetoothserial.print("\r\n+stna=seeedbtslave\r\n"); //set bluetooth name "seeedbtslave"
  bluetoothserial.print("\r\n+stpin=0000\r\n");//set slave pincode"0000"
  bluetoothserial.print("\r\n+stoaut=1\r\n"); // permit paired device connect me
  bluetoothserial.print("\r\n+stauto=0\r\n"); // auto-connection should forbidden here
  delay(2000); // delay required.
  bluetoothserial.print("\r\n+inq=1\r\n"); //make slave bluetooth inquirable
  serial.println("the slave bluetooth inquirable!");
  delay(2000); // delay required.
  serial.println("2 seconds passed");
  //char recstatus;
  //bluetoothserial.print("\r\n+rtsta:xx\r\n");
// recstatus =  bluetoothserial.read();
  //serial.print(recstatus);
  bluetoothserial.flush();
}

sorry our english french :)

regards.

it doable because able myself, can you. first, post in wrong place, should in programming questions section.

when/if post moved , if doesn't, please provide have far, app you're using, link bluetooth module , have tried already.

are familiar terminal program called putty or realterm?

one big thing cringe over, code format , use of code tags. if will, please fix code using arduino software pressing ctrl+t, , post inside [ code ] ... [/ code] tags. # symbol above smiley faces.


Arduino Forum > Using Arduino > Programming Questions > Arduino/Android Bluetooth project


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support