Topic: HC-05 and arduino mega 2650 (Device not reply. Receive time out error)
No compiling errors, it worked 2 times and then it did'nt. I'm connected via Hardware serial (Serial1,pins 19 and 18). I have the baud rate to 9600.
Here is my code:
//////////////////////////////////////////////
// RemoteXY include library //
//////////////////////////////////////////////
// RemoteXY select connection mode and include library
#define REMOTEXY_MODE__HARDSERIAL
#include <SPI.h>
#include <RemoteXY.h>
// RemoteXY connection settings
#define REMOTEXY_SERIAL Serial1
#define REMOTEXY_SERIAL_SPEED 9600
// RemoteXY configurate
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
{ 255,3,0,0,0,31,0,8,13,0,
3,131,28,5,45,17,2,26,1,1,
25,33,19,20,2,31,45,0,1,1,
58,33,19,20,2,31,43,0 };
// this structure defines all the variables of your control interface
struct {
// input variable
uint8_t select_1; // =0 if select position A, =1 if position B, =2 if position C, ...
uint8_t button_1; // =1 if button pressed, else =0
uint8_t button_2; // =1 if button pressed, else =0
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
/////////////////////////////////////////////
// END RemoteXY include //
/////////////////////////////////////////////
#define PIN_BUTTON_1 26
#define PIN_BUTTON_2 24
int ssd = 53;
int ssg = 47;
int UP = 36;
int DOWN= 34;
int i = 0;
int D = 32;
int G = 30;
int j = 0;
void setup()
{
RemoteXY_Init ();
pinMode (PIN_BUTTON_1, OUTPUT);
pinMode (PIN_BUTTON_2, OUTPUT);
pinMode(ssd, OUTPUT);
pinMode(ssg, OUTPUT);
pinMode(UP, INPUT_PULLUP);
pinMode(DOWN, INPUT_PULLUP);
pinMode(D, INPUT_PULLUP);
pinMode(G, INPUT_PULLUP);
SPI.begin();
Serial.begin(9600);
}
void mastervolume()
{
while (RemoteXY.button_1!=1)
{
j++;
if(j>127) j=127;
i++;
if(i>127) i=127;
delay(50);
}
while (RemoteXY.button_2!=1)
{
j--;
if(j<0) j=0;
i--;
if(i<0) i=0;
delay(50);
}
digitalWrite(ssd,LOW);
SPI.transfer(0);
SPI.transfer(j);
digitalWrite(ssd,HIGH);
digitalWrite(ssg,LOW);
SPI.transfer(0);
SPI.transfer(i);
digitalWrite(ssg,HIGH);
}
void volumespeakerdroit (){
while (RemoteXY.button_1!=1)
{
i++;
if(i>127) i=127;
delay(50);
}
while (RemoteXY.button_2!=1)
{
i--;
if(i<0) i=0;
delay(50);
}
digitalWrite(ssg,LOW);
SPI.transfer(0);
SPI.transfer(i);
digitalWrite(ssg,HIGH);
}
void volumespeakergauche()
{
while (RemoteXY.button_1!=1)
{
j++;
if(j>127) j=127;
delay(50);
}
while (RemoteXY.button_2!=1)
{
j--;
if(j<0) j=0;
delay(50);
}
digitalWrite(ssd,LOW);
SPI.transfer(0);
SPI.transfer(j);
digitalWrite(ssd,HIGH);
}
void loop()
{
RemoteXY_Handler ();
if (RemoteXY.select_1==2)
{
volumespeakerdroit();
}
else if (RemoteXY.select_1==0)
{
volumespeakergauche();
}
else if (RemoteXY.select_1==1)
{
mastervolume();
}
{
Serial.println(j);
Serial.println(" ");
Serial.println(i);
Serial.println(" ");
}
digitalWrite(PIN_BUTTON_1, (RemoteXY.button_1==0)?LOW:HIGH);
digitalWrite(PIN_BUTTON_2, (RemoteXY.button_2==0)?LOW:HIGH);
}
Thank you in advance for the help.