AJUDA COM if (t>18 && t<00){printStringWithShift(" ;) ", 100);}

Caros amigos gostaria de uma ajuda para acrescentar  BOM DIA, BOA TARDE, BOA NOITE  nesse esquema 

if (t<18){printStringWithShift(" BOA TARDE!!!!  ", 100);} 

Exibições: 235

As respostas para este tópico estão encerradas.

Respostas a este tópico

if ( t >= 0 && t < 12 ) { texto bom dia }

else if( t >= 12 && t < 18 ) { texto boa tarde }

else { texto boa noite }

vc precisa "cercar" as suas condições, cercar com início e final. Caso contrário vai dar zebra

por exemplo, da meia noite até o 11:59:59 é "bom dia".

Do meio dia  até 17:59:59 é "boa tarde'

E das 18h até 23:59:59 é "boa noite" ==> aqui não precisa "cercar", pois deduz-se que o restante (descrito por ELSE) será esse horário entre as 18h e 23:59:59

.

Oi CF, boa tarde.

Que bom que você começou bem, deu logo bom dia, boa tarde e boa  noite pra nós aqui do LdG.

Agora, não entendi nada.

O que você quer fazer com estes "ifs" se eles já estão definidos.

O que é "t"?

Rui

if (TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second() >18&&00<18) {printStringWithShift(" BOA NOITE... ", 10);}
 if (TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second()>18&&18<00 ){printStringWithShift(" BOA TARDE... ", 10);}
if (TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second()>12 && 12<18){printStringWithShift(" BOM DIA... ", 10);}

O que é  isso,  amigo? 

Pra que escreveu 00<18,  18<00 e 12<18 nas suas condições? Qual foi sua intenção? 

MaxMatrix m(data, load, clock, maxInUse); // define module
byte buffer[10];
RTC_Millis rtc;
void setup(){


//Definicoes do pino SQW/Out



rtc.begin(DateTime(__DATE__, __TIME__));
pinMode(A0,INPUT); //button input
m.init(); // module initialize
m.setIntensity(05 ); // dot matix intensity 0-15

Serial.begin(9600); // serial communication initialize
delay(100);

int t = dht.readTemperature();

int h = dht.readHumidity();
delay(100);


}

void loop(){

printStringWithShift(" HORAS: ", 20);



int t = dht.readTemperature();
int h = dht.readHumidity();

char temp[4];
char Humid[4];
itoa(t,temp,10); // CONVERT int to char!!!!
itoa(h,Humid,10);
DateTime now = rtc.now();


char TimeNow[14];

sprintf(TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second());

sprintf(TimeNow," %.2d:%.2d ",now.hour(),now.minute());

//printStringWithShift(0,130);
//printStringWithShift(TimeNow,100); %d-%02d-%02d %02d:%02d:%02d.%03d
printStringWithShift(TimeNow,30);
printStringWithShift(" ", 30);

// < Menor que
// > Maior que

//if (TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second() >18&&00<18) {printStringWithShift(" BOA NOITE... ", 10);} //if it´ cold...
// if (TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second()>18&&18<00 ){printStringWithShift(" BOA DIA... ", 10);} //if it´ too hot...
//if (TimeNow," %.2d:%.2d:%.2d ",now.hour(),now.minute(),now.second()>12 && 12<18){printStringWithShift(" BOM DIA... ", 10);} //if it´ ok!!!

printStringWithShift(" Temperatura: ", 10);
printStringWithShift(temp, 30);
printStringWithShift("~G ", 30);
printStringWithShift(" Umidade do Ar: ", 10);
printStringWithShift(Humid, 30);
printStringWithShift("% ", 10);
//printStringWithShift("temp: ", 50);
//printStringWithShift(temp, 50);
//printStringWithShift("C ", 50);
/*if (t<10){printStringWithShift(" Brrrrr Que Frio!!!! ", 30);} //if it´ cold...
if (t>25){printStringWithShift(" Que calor!!!!", 30);} //if it´ too hot...
if (t>11 && t<20){printStringWithShift(" ", 30);} //if it´ ok!!!

if (h<50){printStringWithShift(" Umidade baixa!!!! ", 30);} //if it´ cold...
if (h>55){printStringWithShift(" Umidade Alta!!!! ", 30);} //if it´ too hot...
if (h>50 && h<55){printStringWithShift(" ", 30);} //if it´ ok!!!
*/
// < Menor que
// > Maior que


delay(100);
m.shiftLeft(false, true);
}

  

nosso amigo só responde por código.

Acho que isso resolve muitos problemas

https://www.arduino.cc/en/Reference/Else

Caro amigo na verdade eu consegui  com a temperatura , onde T=18<25 onde entre 18E 25  T= ou T baixa OU alta estou tentando usar para a hora entre 18Horas E  00 Horas seria NOITE,nesse sentido.  

E o que vc diz a respeito da minha primeira resposta que te dei?
Tentou aplicar e não deu conta?
Não entendeu nada?
Nem tentou aplicar?
Não percebeu que havia uma sugestão lá?
Ou n.d.a.?

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço