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

Azure OpenAI Architecture Patterns & Deployment Patterns

Sharing some useful links that will help customers architect Azure OpenAI solution using the best practices: (1) Azure OpenAI Landing Zone r...