Skip to main content
added 406 characters in body
Source Link
JVic
  • 125
  • 1
  • 8

firstly, move your pinMode() settings to setup section.

in your code, when the temperature is 21 active pin will be 6 and 8. you should rewrite your code in next ways:

1:

if (t < 22) {
  ... its cold temp ...
} else if (t > 26) {
  ... its hot temp ...
} else {
  ... it's nor temp ...
}

2:

if (t < 22) {
   ... its cold temp ...
}
if (t > 26) {
   ... it's hot temp ...
} 
if (t >= 22 && t <= 26) {
   ... it's nor temp ...
}

and my small advice for u, rewrite in this way, it is more readable

digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);

digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);

digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);

visually changing ENUMS (like LOW or HIGH) more noticeable than changing numbers (6/7/8)

firstly, move your pinMode() settings to setup section.

in your code, when the temperature is 21 active pin will be 6 and 8. you should rewrite your code in next ways:

1:

if (t < 22) {
  ... its cold temp ...
} else if (t > 26) {
  ... its hot temp ...
} else {
  ... it's nor temp ...
}

2:

if (t < 22) {
   ... its cold temp ...
}
if (t > 26) {
   ... it's hot temp ...
} 
if (t >= 22 && t <= 26) {
   ... it's nor temp ...
}

firstly, move your pinMode() settings to setup section.

in your code, when the temperature is 21 active pin will be 6 and 8. you should rewrite your code in next ways:

1:

if (t < 22) {
  ... its cold temp ...
} else if (t > 26) {
  ... its hot temp ...
} else {
  ... it's nor temp ...
}

2:

if (t < 22) {
   ... its cold temp ...
}
if (t > 26) {
   ... it's hot temp ...
} 
if (t >= 22 && t <= 26) {
   ... it's nor temp ...
}

and my small advice for u, rewrite in this way, it is more readable

digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);

digitalWrite(6, LOW);
digitalWrite(7, HIGH);
digitalWrite(8, LOW);

digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);

visually changing ENUMS (like LOW or HIGH) more noticeable than changing numbers (6/7/8)

Source Link
JVic
  • 125
  • 1
  • 8

firstly, move your pinMode() settings to setup section.

in your code, when the temperature is 21 active pin will be 6 and 8. you should rewrite your code in next ways:

1:

if (t < 22) {
  ... its cold temp ...
} else if (t > 26) {
  ... its hot temp ...
} else {
  ... it's nor temp ...
}

2:

if (t < 22) {
   ... its cold temp ...
}
if (t > 26) {
   ... it's hot temp ...
} 
if (t >= 22 && t <= 26) {
   ... it's nor temp ...
}