---
# System prepended metadata

title: Arduino code

---

# Arduino code


```
const int hot = 20; //set hot parameter
const int cold = 10; //set cold parameter
void setup() {
  pinMode(A2, INPUT); //sensor
  pinMode(2, OUTPUT); //orange
  pinMode(3, OUTPUT); //green
  pinMode(4, OUTPUT); //red
  Serial.begin(9600);
}
void loop() {
  int sensor = analogRead(A2);
  float voltage = (sensor / 1024.0) * 5.0;
  float tempC = (voltage - .5) * 100;
  // float tempF = (tempC * 1.8) + 32;
  // Serial.print("temp: ");
  // Serial.print(tempF);
  if (cold > 0 && tempC <= cold) { //cold
    digitalWrite(3, HIGH);
    digitalWrite(2, LOW);
    digitalWrite(4, LOW);
    Serial.println(" It's Green.");
  }
  else if (tempC > cold && tempC < hot) { 
    digitalWrite(2, HIGH);
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    Serial.println(" It's Orange.");
  }
  else if (tempC >= hot) {
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    Serial.println(" It's Red.");
  }
  delay(10);
}
```