void setup() {
  // put your setup code here, to run once:
  Serial1.begin(9600);// serial communication 9600 bps
  pinMode(26, INPUT); // sets pinmode 26 as input
  pinMode(16,OUTPUT); // sets pinmode 16 as output
  
}

void loop() {
  // put your main code here, to run repeatedly:
  const float bt=3950;
  float tval=analogRead(26); //reading temperature sensor value
  float tempc=1/(log(1/(1023.0/tval-1))/bt+1.0/298.15)-273.15; // converting it into celcius value
  Serial1.println(tempc); // printing celcius value
  if (tempc>40.0) {
    digitalWrite(16,HIGH); // sets pin 16 as High 5V
    delay(1000);// delays by 2s
  }
  else {
    digitalWrite(16,LOW); // sets pin 16 as Low 0V
    delay(1000);// delays by 2s
  }

}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT