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); }
Hello, i had bought the Quick start kit, and i don;t exactly know which one is the temp.sensor. there is something which resembles the one shown here, but not exactly. for one thing, it has a small bu;ge on one side, and there appear to be 4 legs out of which one seems to be broke. is it the temp.sensor? also, please note that i did not get any sheet along with my order, so kindly request you to provide one if possible.. thanks!
ReplyDeleteAbhilash.P
Dear , plz see one is transistor and another is temp.sensor .
ReplyDeleteplz read the last code on printed in that if "DZ" then its temp.sensor another is transistor.
my name is ilyas ahmed i bought the kit and made connections as there but i am not getting output if i click serial monitor then it is continiusly printing the values like 458
ReplyDeletethe temp cant be 458 na so ples can u help me
can u send a snapshot of the serial moniter and your project (arduino and breadboard)
DeleteHi. Why do you divide temp sensor reading "analogRead(2)/2" ?
ReplyDelete