Hello, I'm in the process of developing an app that aims to establish a connection between a smartphone and a BLE JDY-16 module paired with an Arduino Uno featuring three buttons. However, I'm encountering an issue where the app isn't able to transmit input commands to the Arduino or retrieve buttons status information from it. i would greatly appreciate any assistance in resolving this matter. Thank you in advance for your help.
Code:
char Incoming_value = 0;
int ledPin = 7;
unsigned long offsetTime;
unsigned long elapsedTime;
void setup()
{
Serial.begin(9600);
pinMode(4, INPUT);
pinMode(2, INPUT);
pinMode(7, INPUT);
}
void loop()
{
if(Serial.available() > 0)
{
Incoming_value = Serial.read();
if(Incoming_value == '1')
{
offsetTime = millis();
// Serial.print("Time: ");
//Serial.println(offsetTime);
}
}else if(digitalRead(4)==HIGH)
{
elapsedTime = millis()- offsetTime;
delay(200);
Serial.print("Button_Pressed");
Serial.print('\n');
Serial.print(elapsedTime);
Serial.print('\n');
Serial.print("Button_4");
Serial.print('\n');
}else if(digitalRead(2)==HIGH)
{
elapsedTime = millis()- offsetTime;
delay(200);
Serial.print("Button_Pressed");
Serial.print('\n');
Serial.print(elapsedTime);
Serial.print('\n');
Serial.print("Button_1");
Serial.print('\n');
}
else if(digitalRead(7)==HIGH)
{
elapsedTime = millis()- offsetTime;
delay(200);
Serial.print("Button_Pressed");
Serial.print('\n');
Serial.print(elapsedTime);
Serial.print('\n');
Serial.print("Button_3");
Serial.print('\n');
}
else{
//Serial.print("l");
}
}