Arduino
Code Downloads

Arduino C. Code

 
 

Arduino using LM35 Temperature Celcius and Fahrenheit CODE
 


/***********************************
  Built and coded By Hassan Ali
  May 29th 2014
  
  LM35 Centigrade Sensor
************************************/

// http://www.abrushfx.com

//**********************************

int temppin = A0; //analog pin input, you can chage this if you change input 
int LEDPin = 13; //digital pin output for light, you can change this to whatever output
int celSecond;
int celFirst;
int minDegreesF = 70; //change your min value for lower temps
int maxDegreesF = 95; //change your max values for higher temps


void setup(){
  Serial.begin(9600);
  pinMode(LEDPin, OUTPUT);
  celSecond =0;
}

void loop(){
  celFirst = getCelcius(temppin);
  if(celFirst!=celSecond)
  {
    Serial.print("Celcius: ");
    celSecond = celFirst;
    Serial.println(celFirst);
    Serial.print("Fahrenheit: ");
    Serial.println(getF(temppin));
    setLight((celFirst*1.8) + 32.00); 
    delay(1000); 
  }
  
}


float getCelcius(int pin){
 float tempC = analogRead(pin);  
 return (5*tempC*100.0)/1024.0; 
}

//call this function for a Fahrenheit Value
float getF(int pin){
  return ((getCelcius(pin)*1.8) + 32.00); //pin number is a0
}

//using F values
void setLight(float temp){
  int mappedVal = map(temp, minDegreesF,maxDegreesF, 2,254);
  analogWrite(LEDPin, mappedVal);
}



Download Arduino Code


 

 

 

 
Tags

Arduino

Arduino Mega 2560

LED Cube 16x2

LM35 temperature Sensor

LED Cube 16x2

LED

LED Cube Display