Overview In this laboratory, you will learn how to program Arduino to connect to a temperature sensor LM35 for temperatu
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Overview In this laboratory, you will learn how to program Arduino to connect to a temperature sensor LM35 for temperatu
Modify the three ranges of temperature from the programming code and demonstrate the alteration of temperatures from LED (red), to LED (green) and to LED (Blue) (or any three colours of LEDs are also acceptable).
/* Lab 05a - Temperature measurement For Tinkercad TMP36 Only int celsius = 0; int fahrenheit = 0; void setup() { pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); Serial.begin(9600); void loop() { celsius - map(((analogRead(AO) -20) * 3.04), 0, 1023, -40, 125); //Calibration for TMP36 fahrenheit – ((celsius * 9)/5 + 32); Serial.print("TEMPRATURE = "); Serial.print(celsius); Serial.print("\n"); Serial.print("TEMPRATURE = "); Serial.print(fahrenheit); Serial.print("F\n"); Serial.println(); if (celsius < 15) 1/temperature <=15 1 digitalWrite(13,LOW); digitalWrite(12, LOW); digitalWrite(11, HIGH); i/temperature between 12 and 26 else if (celsius-15 && celsius <-26) 7 digitalWrite(13,LOW); digitalWrite(12, HIGH): digitalWrite(11, LOW); } else { digitalWrite(13, HIGH); digitalWrite(12, LOW): digitalWrite(11, LOW);
Procedures Step 1 - connect analog Pin A0 from the Arduino board to the temperature sensor (LM35) Pin 2 (middle leg) on the breadboard (as shown in the diagram above). Step 2 - connect Pin 1 (Left 1) of the LM35 on the breadboard to the +5V power supply on the Arduino Board. Step 3 - connect Pin 3 (Right 1) of the LM35 on the breadboard to the GND column on the breadboard. Step 4 - connect Pin 13 from the Arduino board to one end of a 2200 resistor on the breadboard. Step 5 - connect another end of resistor to the Red LED's long leg (Anode) via the breadboard. Step 6 - connect the LED's short leg (Cathode) to the ground column on the breadboard. Step 7 – repeat steps 4-6 above to connect the extra two LEDs (pins 12 and 11) on the Arduino board (It is okay to use whatever LED colours are available.) 1 21/22 Sem. 2 Microcontrollers (CCIT-4064) Step 8 - connect the ground column to the 'GND' pin on the Arduino board Step 9 - open the Arduino IDE software to type the programming code Step 10 - save your file with the file name 'Lab5a_LM35'. Step 11 - connect, compile and upload the program to the Arduino board,