Getting numbers from bluetooth and using them

Hi
I was trying to make my lamp to wake me up with turning it on
I thought that i can send that times hour and minute and i can send the hour and minute of the alert time.
I tried to do that project but it doesnt work. Idk y. Im not able to pick numbers from bluetooth together so i tried to pick them one by one. So here is my code. I would be very happy if u help me.
(Idc about codes desing or etc. (: it would be great if it just works ! )

#include <SoftwareSerial.h>
boolean a=0;
boolean b=0;
boolean c=0;
boolean d=0;
boolean e=0;
boolean f=0;
boolean g=0;
boolean h=0;
int role=4;
int buzzer=8;
int x1=0;
int y1=0;
int z1=0;
int q1=0;
int x2=0;
int y2=0;
int z2=0;
int q2=0;
boolean alarmsesi=0;

SoftwareSerial bt_iletisim(9, 8); // RX,TX

void setup()
{
Serial.begin(9600);
bt_iletisim.begin(9600);
pinMode(role,OUTPUT);
digitalWrite (role,HIGH);
digitalWrite (buzzer,LOW);

}

void loop(){

int dg=bt_iletisim.read();
Serial.println(dg);

if((a==0)&&(bt_iletisim.available())){

if(dg==48){
x1=0;
a=a+1;}

if(dg==49){
x1=1;
a=a+1;}

if(dg==50){
x1=2;
a=a+1;}

if(dg==51){
x1=3;
a=a+1;}

if(dg==52){
x1=4;
a=a+1;}

if(dg==53){
x1=5;
a=a+1;}

if(dg==54){
x1=6;
a=a+1;}

if(dg==55){
x1=7;
a=a+1;}

if(dg==56){
x1=8;
a=a+1;}

if(dg==57){
x1=9;
a=a+1;}
Serial.println(x1);
delay(250);
dg=0;
}

if((a==1)&&(bt_iletisim.available())){

if(dg==48){
x2=0;
b=b+1;}

if(dg==49){
x2=1;
b=b+1;}

if(dg==50){
x2=2;
b=b+1;}

if(dg==51){
x2=3;
b=b+1;}

if(dg==52){
x2=4;
b=b+1;}

if(dg==53){
x2=5;
b=b+1;}

if(dg==54){
x2=6;
b=b+1;}

if(dg==55){
x2=7;
b=b+1;}

if(dg==56){
x2=8;
b=b+1;}

if(dg==57){
x2=9;
b=b+1;}
Serial.println(x2);
delay(250);
dg=0;
}

if((b==1)&&(bt_iletisim.available())){

if(dg==48){
y1=0;
c=c+1;}

if(dg==49){
y1=1;
c=c+1;}

if(dg==50){
y1=2;
c=c+1;}

if(dg==51){
y1=3;
c=c+1;}

if(dg==52){
y1=4;
c=c+1;}

if(dg==53){
y1=5;
c=c+1;}

if(dg==54){
y1=6;
c=c+1;}

if(dg==55){
y1=7;
c=c+1;}

if(dg==56){
y1=8;
c=c+1;}

if(dg==57){
y1=9;
c=c+1;}
Serial.println(y1);
delay(250);
dg=0;
}

if((c==1)&&(bt_iletisim.available())){

if(dg==48){
y2=0;
d=d+1;}

if(dg==49){
y2=1;
d=d+1;}

if(dg==50){
y2=2;
d=d+1;}

if(dg==51){
y2=3;
d=d+1;}

if(dg==52){
y2=4;
d=d+1;}

if(dg==53){
y2=5;
d=d+1;}

if(dg==54){
y2=6;
d=d+1;}

if(dg==55){
y2=7;
d=d+1;}

if(dg==56){
y2=8;
d=d+1;}

if(dg==57){
y2=9;
d=d+1;}
Serial.println(y2);
delay(250);
dg=0;
}

if((d==1)&&(bt_iletisim.available())){

if(dg==48){
z1=0;
e=e+1;}

if(dg==49){
z1=1;
e=e+1;}

if(dg==50){
z1=2;
e=e+1;}

if(dg==51){
z1=3;
e=e+1;}

if(dg==52){
z1=4;
e=e+1;}

if(dg==53){
z1=5;
e=e+1;}

if(dg==54){
z1=6;
e=e+1;}

if(dg==55){
z1=7;
e=e+1;}

if(dg==56){
z1=8;
e=e+1;}

if(dg==57){
z1=9;
e=e+1;}
Serial.println(z1);
delay(250);
dg=0;
}

if((e==1)&&(bt_iletisim.available())){

if(dg==48){
z2=0;
f=f+1;}

if(dg==49){
z2=1;
f=f+1;}

if(dg==50){
z2=2;
f=f+1;}

if(dg==51){
z2=3;
f=f+1;}

if(dg==52){
z2=4;
f=f+1;}

if(dg==53){
z2=5;
f=f+1;}

if(dg==54){
z2=6;
f=f+1;}

if(dg==55){
z2=7;
f=f+1;}

if(dg==56){
z2=8;
f=f+1;}

if(dg==57){
z2=9;
f=f+1;}
Serial.println(z2);
delay(250);
dg=0;
}

if((f==1)&&(bt_iletisim.available())){

if(dg==48){
q1=0;
g=g+1;}

if(dg==49){
q1=1;
g=g+1;}

if(dg==50){
q1=2;
g=g+1;}

if(dg==51){
q1=3;
g=g+1;}

if(dg==52){
q1=4;
g=g+1;}

if(dg==53){
q1=5;
g=g+1;}

if(dg==54){
q1=6;
g=g+1;}

if(dg==55){
q1=7;
g=g+1;}

if(dg==56){
q1=8;
g=g+1;}

if(dg==57){
q1=9;
g=g+1;}
Serial.println(q1);
delay(250);
dg=0;
}

if((g==1)&&(bt_iletisim.available())){

if(dg==48){
q2=0;
h=h+1;}

if(dg==49){
q2=1;
h=h+1;}

if(dg==50){
q2=2;
h=h+1;}

if(dg==51){
q2=3;
h=h+1;}

if(dg==52){
q2=4;
h=h+1;}

if(dg==53){
q2=5;
h=h+1;}

if(dg==54){
q2=6;
h=h+1;}

if(dg==55){
q2=7;
h=h+1;}

if(dg==56){
q2=8;
h=h+1;}

if(dg==57){
q2=9;
h=h+1;}
Serial.println(q2);
delay(250);
dg=0;
}

if(h==1){
int saat;
int alarm;
int sayac;
x1=x110;
x1=x1+x2;
x1=x1
3600;
y1=y110;
y1=y1+y2;
y1=y1
60;
z1=z110;
z1=z1+z2;
z1=z1
3600;
q1=q110;
q1=q1+q2;
q1=q1
60;
saat=x1+q1;
alarm=z1+q1;
Serial.print(“saat=”);
Serial.println(saat);
Serial.print(“alarm=”);
Serial.println(alarm);

if(saat>alarm){
sayac=43200-abs(saat-alarm);
sayac=sayac-55;}

if(alarm>saat){
sayac=alarm-saat;
sayac=sayac-55;}

delay(sayac);
digitalWrite (role,LOW);
delay(1000);
delay(50);
alarmsesi=alarmsesi+1;

while(alarmsesi==1){
a=0;
b=0;
c=0;
d=0;
e=0;
f=0;
g=0;
h=0;
x1=0;
y1=0;
z1=0;
q1=0;
alarm=0;
sayac=0;
saat=0;
delay(1000);
digitalWrite(buzzer,HIGH);
delay(1000);
digitalWrite(buzzer,LOW);
}
}

}

alarm code failure.txt (6.54 KB)

Hi,

Please read “how to use this forum

… And pay special attention to the part about posting code:)

Thanks,

Zeb