Arduino - Sensor Interfacing - LM35 Temperature Sensor- How To?
Arduino - Sensor Interfacing - LM35 Temperature Sensor- How To?
Working with Sensors - LM35
So lets get started with some sensors, LM35 is a simple temperature sensor. LM35 has 3 pins. Refer to the following image for the pin mappings
Now
time for the program. Try the following program. Pressing the Button
changes the current active color of the RGB LED & prints the current
temperature value to the Serial Monitor and varying the trimpot changes
the intensity of the color [RGB_button_lm35.ino]
So lets get started with some sensors, LM35 is a simple temperature sensor. LM35 has 3 pins. Refer to the following image for the pin mappings
This is the LM35 as it looks |
The LM35 pin Mapping. Note: The image on the left is a BOTTON view. This is how you will find it in the Product Datasheet |
Place the LM35 as shown |
Connect Wires to Supply & Ground. Take a wire from the middle pin and connect it to Analog In 2 of the Arduino |
Heres the finished Setup |
/* Pressing the Button changes the current active color of the RGB LED & prints the current temperature value to the Serial Monitor and varying the trimpot changes the intensity of the color */ int intensity = 0, pin = 9; void setup() { pinMode(2,INPUT); Serial.begin(9600); } void loop() { if(digitalRead(2)==0) // Switch being pressed { Serial.print("Temperature is : "); int temp = analogRead(2)/2; Serial.println(temp); if(pin<11) pin++; else pin=9; analogWrite(9,0); analogWrite(10,0); analogWrite(11,0); while(digitalRead(2)==0); delay(100); } intensity = analogRead(0)/4; analogWrite(pin,intensity); Serial.print(pin); Serial.print(" "); Serial.println(intensity); }
No comments:
Post a Comment