Saturday, 5 November 2016

Temperature Sensor

The following is the code for using the Temperature Sensor:


const int tempSensorOutputPin = A0;

const int firstLEDPwrPin = 4;
const int secondLEDPwrPin = 3;
const int thirdLEDPwrPin = 2;

int tempSensorValue = 0;

void setup() {
  Serial.begin(9600);
  for(int pinLoop = 2; pinLoop <=4; pinLoop++){
    pinMode(pinLoop, OUTPUT);
    digitalWrite(pinLoop,LOW);
  }
}

void loop() {
  run();  
}

void run(){
  
  tempSensorValue = analogRead(tempSensorOutputPin);
  float voltage = (tempSensorValue / 1024.0) * 5.0;
  float temp = (voltage - 0.5) * 100;
  Serial.print("Temp = ");
  Serial.println(temp);
  delay(1000);
  
}

No comments:

Post a Comment

Using Handlebar Prompt in Semantic Kernal

> dotnet add package Microsoft.SemanticKernel.PromptTemplates.Handlebars --version 1.30.0 using Microsoft . SemanticKernel ; using Micr...