訂閱:
張貼留言 (Atom)
I put both design, research, and art projects here, also including references and notes. I am trying to use here as a thinking platform now. You also can brow my another web site: (https://sites.google.com/site/scottiehuang0107/). Here has more clear description for my works. Whereas, if you have any comments or interesting can contact to me. [scottie.c.c.huang@gmail.com; 886-911331196]
1 則留言:
/* Analog Read of LM35 temperature sensor
* --------------------------------------
*
* The Analog to Digital Converter (ADC) converts analog values into a digital approximation
* based on the formula ADC Value = sample * 1024 / reference voltage (+5v). So with a +5 volt
* reference, the digital approximation will = input voltage * 205. (Ex. 2.5v * 205 = 512.5)
*
* The LM35 is a precision linear temperature sensor that supplies 10mv per degree Celsius.
* This means at 15 degrees Celsius, it would produce a reading of .150v or 150 millivolts.
* Putting this value into our ADC conversion ( .15v * 205 = 30.75) we can get a close
* approximation of the Celsius temperature by dividing the digital input count by 2.
*
* If the LM35 were supplied by a different reference voltage (9v or 12v) we would have
* to use a different conversion method. For this circuit, dividing by 2 works well.
*
* The LM25 has three legs and looks like a transistor. The two outside legs are
* +5v and Ground, and the middle leg develops the sample voltage.
* LM35 Sources: BGmicro.com and Jameco.com Search term: LM35 Approx $1.75
*
* /|---> Gnd 18K ohm
* | |-----------+---/\/\/\/-----> Gnd
* \|---> +5v |
* +----------- Analog Input pin 5
*
*/
int inPin = 5; // select the input pin for analog temp value
int inVal; // integer value for input read from sensor
int delayVal = 1000; // delay value to read once a second
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
}
void loop() {
inVal = analogRead(inPin); // read the value from the sensor
inVal /= 2; // convert 1024 steps into value referenced to +5 volts
Serial.print(inVal); // print input value
Serial.print(" Celsius, "); // print Celsius label
Serial.print((inVal * 9)/ 5 + 32); // convert Celsius to Fahrenheit
Serial.println(" Fahrenheit"); // print Fahrenheit label
delay(delayVal); // delay the program for the requested time
}
張貼留言