I have arduino pro mini and want to control an led (on/off) using bluetooth(hc-05) with the Arduroid app. The problem is when i am using arduino uno the ble works fine but its not working with pro mini. The code is simple and just turn on and off the led.
I have uploaded blink example on pro mini and it works fine so my pro mini is Ok.
PLx help
Code:
int ledPin =13;
int state=0;
int flag=0;
void setup() {
pinMode(ledPin,OUTPUT);
digitalWrite(ledPin,LOW);
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0){
state= Serial.read();
flag=0;
}
if (state == '0'){
digitalWrite(ledPin,LOW);
if(flag == 0){
Serial.println("LED off");
flag =1;
}
}
else if (state == '1')
digitalWrite(ledPin,HIGH);
if (flag ==0){
Serial.println("LED on");
flag =1;
}
}