The LED is indeed still flashing. I used a code from an early stage of the same project ,done by somebody else, where the pro micro is connected to a SEED Studio Bluetooth Shield instead and to a PC Base Station as well doing practically the same job.
What I am currently doing is actually the same thing but instead of using the Bluetooth Shield I use the HC-06 Keyes BT_BOARD v2.0 to achieve miniaturization. I think the bluetooth shield is not using the exact same bluetooth chip as the HC-06, but they are very similar. Also, at this point connecting to pc base station is not my priority, I just want to connect to the Android app.
This is the code used for the previous stage of the project, can it be modified somehow?:
#define READINGCOUNT 25
//Global Variables
int _count; //index
int _delayCount=0; //counter to generate delay for sending readings every X seconds
int _state; //state machine - current state
String _readings[READINGCOUNT] = {"43","63","44","47","50","46","44","60","52","47","51","50","49","63","57","52","57","51","47","44","43","42","42","42","42"};
char _btRxData; //Most recent received byte from BT Shield
String _btRxBuff=""; //Local buffer for received data
char _pcRxData; //Most recent received byte from PC (over serial)
void setup()
{
//Initialise Serial Port to PC
Serial.begin(9600);
//Initialise BT Shield
BluetoothInit();
Serial.println("Bluetooth Hardware Initiated");
Serial.flush();
_count=0;
}
void loop()
{
//If new byte of data to receive from BT Shield
if(Serial1.available())
{
_btRxData = Serial1.read(); //Read it
_btRxBuff += _btRxData; //Add it to buffer
Serial.print(_btRxData); //Debug: Send to PC Console
}
//If new byte of data to receive from PC
if(Serial.available())
{
_pcRxData = Serial.read(); //Read it
Serial1.print(_pcRxData); //Relay to BT Shield
}
//Check for disconnection
if(_btRxBuff.indexOf("+BTSTATE:1") != -1) //BT STATE 1 indicates a disconnection
{
Serial.println("Debug: Disconnection Detected");
Serial1.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
delay(2000); // This delay is required.
Serial1.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
delay(2000); // This delay is required.
Serial.println("Debug: Earpiece Is Inquiring Again");
_btRxBuff=""; //Clear buffer
_state=0;
}
//Detect disconnect when remote device drops off (disconnection not properly indicated by remote device)
if(_btRxBuff.indexOf("CONNECT:FAIL") != -1)
{
Serial.println("Debug: Error Occurred");
Serial1.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
Serial1.print("\r\n+INQ=0\r\n"); //make the slave bluetooth inquirable
delay(2000); // This delay is required.
Serial1.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
delay(2000); // This delay is required.
Serial.println("Debug: Earpiece Is Inquiring Again");
_btRxBuff="";
_state=0;
}
//Main FSM logic
switch(_state)
{
case 0:
//Idle state (waiting for connection)
if(_btRxBuff.indexOf("+BTSTATE:4") != -1) //If successful connection detected?
{
//Connection has been established - clear local buffer
Serial.println("Debug: Connection Established");
_count=0;
_delayCount=0;
_btRxBuff="";
_state=1;
}
break;
case 1:
//State which starts sending readings
//Send reading every X * 1ms (current delay is 2 seconds)
//This method of delay avoids long "delay(2000)" at bottom, which would cause device to receive data 1 byte per second! (that wouldn't be good!)
if(_delayCount == 2000)
{
if(_count < READINGCOUNT) //Send the next reading in the readings array
{
Serial.println(_readings[_count]);
Serial1.print(_readings[_count]);
_count++;
}
else _count=0; //If reached end, reset
_delayCount=0; //Reset delay counter
}
else _delayCount++;
break;
default:
break;
}
//Common delay for each cycle (used in order to send data every X seconds)
delay(1);
}
void BluetoothInit()
{
Serial1.begin(38400);
Serial1.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
Serial1.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
Serial1.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
Serial1.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
delay(2000); // This delay is required.
Serial1.print("\r\n+LOSSRECONN=0\r\n");
delay(2000);
Serial1.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
delay(2000); // This delay is required.
Serial1.flush();
}
Thank you