Monday, April 1, 2013

Arduino Uno LM335AZ Temp Sensor

April 1 2013

So I set off last week to use my new Arduino.  I had some LM335AZ temp sensors laying around from another project that I never used.  So I decided to use them as my first Arduino project.  Well needless to say I dont know much about eletronics, I do know how to code.  That is what lead me to this path.

LM335AZ

Arduino Uno
 
 
 
First project
Put the to together.
 
 
 
 
Time for the code, which most people did the code wrong.  You should use double or floats for all for all of the calculations.  To use a double or a float you must add a decimal point for all static numbers.  So if you want to say 5, it needs to look like this "5.0".  If you do not do that it will down convert the numbers to ints.
 
int KelvinC=273;
double _sensorValue = analogRead(0);
float _Kelvin = (((_sensorValue / 1023.0) * 5.0) * 100.0); // convert 
float _Celsius=_Kelvin-KelvinC;
float _Fahrenheit=(_Celsius)*(9.0/5.0)+32.0;


No comments:

Post a Comment