Advertisement
mivebe

Thermistor amplitude control

Nov 24th, 2023
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.61 KB | Software | 0 0
  1.  
  2. const int thermistorPin = A0;
  3. const int indicatorPin = 2;
  4. int sensorValue;
  5. float temperature;
  6.  
  7. void setup() {
  8.   pinMode(LED_BUILTIN, OUTPUT);
  9.   pinMode(indicatorPin, OUTPUT);
  10.  
  11.   Serial.begin(9600);
  12. }
  13.  
  14. void loop() {
  15.  
  16.   sensorValue = analogRead(thermistorPin);
  17.   temperature = (sensorValue - 300) * 0.116;
  18.  
  19.   Serial.println(sensorValue);
  20.   Serial.println(temperature);
  21.  
  22.   if (temperature < 24) {
  23.     digitalWrite(indicatorPin, HIGH);
  24.   } else if (temperature > 27) {
  25.     digitalWrite(LED_BUILTIN, HIGH);
  26.   }
  27.  
  28.   delay(2000);
  29.  
  30.   digitalWrite(indicatorPin, LOW);
  31.   digitalWrite(LED_BUILTIN, LOW);
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement