Sorry the other images are attach here,
So the codes continue, if the person put A in the keyboard the program ask the code of the sector
and compares it to the fist list and code i put whit the sectors
if(regular_relogio == 2)// Se já acabou de regular relógio, ou se ele já está regulado
{
if(pegar_codigo == 0)// Pegar os codigos(Menu códigos inicial)
{
lcd.setCursor(0,0);
lcd.print(F("Entre o Codigo"));
lcd.setCursor(0,1);
lcd.print(F(" do setor:"));
lcd.setCursor(0,2);
if(cont_print_uma_vez == 0){
lcd.print(F(" ___ "));
cont_print_uma_vez = cont_print_uma_vez +1 ;}
if (key)
{ if (key == '*')// corrige os dados reiniciando o menu
{
cont_setor = 1;
lcd.print(F(" ___"));
}
else if(key == '#') // COnfirma a código e vai para o próximo menu
{
cont_setor = 4;
pegar_codigo = 1;
lcd.clear();
}
else
{
if(cont_setor == 1)
{
setor_1 = key;
lcd.setCursor(0,2);
lcd.print(F(" "));
lcd.print(F("__"));
lcd.print(setor_1);
}
if(cont_setor == 2)
{
setor_2 = setor_1;
setor_1 = key;
lcd.setCursor(0,2);
lcd.print(F(" "));
lcd.print(F("_"));
lcd.print(setor_2);
lcd.print(setor_1);
}
if(cont_setor == 3)
{
setor_3 = setor_2;
setor_2 = setor_1;
setor_1 = key;
lcd.setCursor(0,2);
lcd.print(F(" "));
lcd.print(setor_3);
lcd.print(setor_2);
lcd.print(setor_1);
}
cont_setor = cont_setor + 1;
}
}
}
if(pegar_codigo == 1)//pega os valores que o usario digitou e trasforma elas no codigo
{int setor1 = setor_1 - 48;
int setor2 = setor_2 - 48;
int setor3 = setor_3 - 48;
codigo = (setor3 *100)+ (setor2*10) + (setor1);
lcd.setCursor(0,0);
It converts the codes in char to int, so that's why the -48.
so it asks for confirmation, and if the sector in invalid or wrong it returns and asks to the code of the sector again
lcd.print(F("Confirma ?"));// menu de confirmação do setor selecionado
lcd.setCursor(0,1);
lcd.print(setor);
lcd.setCursor(0,3);
lcd.print(F("A - S / B - N"));
if(key == 'B')// Se B não confirma e volta ao menu código inicial
{
pegar_codigo = 0;// Reinicia os contadores para voltar no menu códigos inicial
cont_print_uma_vez= 0;
cont_setor = 1;
setor_1 = '0';// Reinicia os valores
setor_2 = '0';
setor_3 = '0';
}
else if(key == 'A')// se confirmar com A o programa pode seguir, e verificar
{
if(setor == " ERRO : Setor Invalido !")// se o setor for inválido e a pessoa confirmar, volta ao menu código inicial
{pegar_codigo = 0;
cont_print_uma_vez= 0;
cont_setor = 1;
setor_1 = '0';// Reinicia os valores
setor_2 = '0';
setor_3 = '0';
}
else{// caso a pessoa confime e o setor for válido, o programa procede para o próximo menu.
pegar_codigo = 2;
lcd.clear();
} }
}


