Question

Write an Arduino code to read the current temperature using the LM35 temperature sensor. The code should include the followin

0 0
Add a comment Improve this question Transcribed image text
Answer #1

void setup() {

pinMode(A0, INPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

pinMode(11, OUTPUT);

Serial.begin(9600);

}

void loop() {

int sensor = analogRead(A0);

float voltage = (sensor / 1024.0) * 5.0;

float tempC = (voltage - .5) * 100;

float tempF = (tempC * 1.8) + 32;

Serial.print("temp: ");

Serial.print(tempF);

If(tempF > 45){

digitalWrite(9, HIGH);

delay(1000);

digitalWrite(10, HIGH);

delay(2000);

digitalWrite(11, HIGH);

delay(1000);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

Delay(500);

digitalWrite(9, HIGH);

digitalWrite(10, HIGH);

digitalWrite(11, HIGH);

delay(60000);

digitalWrite(9, LOW);

digitalWrite(10, LOW);

digitalWrite(11, LOW);

}

else

{
digitalWrite(11, HIGH);

delay(180000);

digitalWrite(11, LOW);

delay(1000);

}

Add a comment
Know the answer?
Add Answer to:
Write an Arduino code to read the current temperature using the LM35 temperature sensor. The code...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Looking for help to create the arduino program for this in C. dont need the breadboard...

    Looking for help to create the arduino program for this in C. dont need the breadboard information just the arduino code to run it all, and as an expection to handle a case where a letter not 'g' or 's' to send output invalid response and not stop the exection of the blinking based You are to create a new application that will execute on your Arduino platform upon the Blink example that is available in the Arduino Examples folder...

  • MICROCONTROLLERS (Arduino Uno) Submit a schematic drawing and source code: Operating a simple DC...

    MICROCONTROLLERS (Arduino Uno) Submit a schematic drawing and source code: Operating a simple DC motor with a Potentiometer Minimum 3 speeds; fast, slow, stop (0/mph) At fast, green LED on At slow, yellow LED on At stop, red & blue LEDs alternating on/off Thank you in advance

  • LM35 Temperature Sensor is connected on Pin AD of Arduino and LED is connected on Pin...

    LM35 Temperature Sensor is connected on Pin AD of Arduino and LED is connected on Pin 3. Write a Program to illuminate the LED based on the Temperature sensor value. Program should also display the temperature in Celsius on Serial Monitor Temperature in Celsius Sensor Input value 0.48828125 OO UNO ARDUINO .. ....

  • Assignment 2: Simulate a Sensor to control an alarm Before you attempt this assignment, it is...

    Assignment 2: Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond...

  • Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you...

    Simulate a Sensor to control an alarm Before you attempt this assignment, it is suggested you understand circuits (and the Arduino code) 1B and 1C. Sensor That being said, in this assignment, we’ll be mimicking an Infrared Sensor (detects objects) by utilizing the potentiometer. The potentiometer will provide us voltage potential that we can vary from 0V to 5V (similar to 1B). This voltage potential represents the output of a sensor. Assume the sensor cannot detect anything beyond 10 yards....

  • Microcontroller programming exercises by practice on Arduino: Write a program that lights a green LED attached...

    Microcontroller programming exercises by practice on Arduino: Write a program that lights a green LED attached to pin 3. The green LED should turn off after a button attached to pin4 has been pushed and released 3 times. Each time the button is pushed it will turn on a red LED attached to pin 7 and turn off a yellow LED attached to pin 9. When the button is not pushed the red LED will be off and the yellow...

  • Problem 10 Use the following circuit to answer the next four questions. Recall that the resistor...

    Problem 10 Use the following circuit to answer the next four questions. Recall that the resistor enclosed in a circle with two arrows is a photoresistor/photocell. The photoresistor will be used to control the circuit's behavior. If the room is dark, the red LED will illuminate. In moderate light, the yellow LED will illuminate. In bright light, the green LED will illuminate. The reading from the photoresistor at pin AO is assigned to the integer variable, "photo_value. ☆ ☆ Red...

  • You are to create a new application that will execute on your Arduino platform based upon...

    You are to create a new application that will execute on your Arduino platform based upon the Blink example that is available in the Arduino Examples folder that you downloaded as part of the IDE. Your application will use a toggle switch to interface with the user. The application will operate by controlling the LEDs based upon the position of the toggle switch. If the user moves the LEDs until new user input is provided. When the user moves the...

  • need this in beginner arduino coding (simple ) ARDUINO 1. Complete the following problem using Arduino...

    need this in beginner arduino coding (simple ) ARDUINO 1. Complete the following problem using Arduino IDE Write a program to detect the temperature of the environment and provide audio and visual cue to user using LED, and Piezo sensor to notify the occupants about a potential fire in the building. In addition, upon fire detection entrance and exit should be opened using a servo motor. (a) Items used & Circuit Schematic (5points) (b) All sensor functionality included based on...

  • C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED...

    C CODE LANGUAGE. MSP430. #include <msp430fr6989.h> #define redLED BIT0 // Red LED at P1.0 #define greenLED BIT7 // Green LED at P9.7 #define BUT1 BIT1 // Button S1 at P1.1 #define BUT2 BIT2 // Button S2 at P1.2 void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop the Watchdog timer PM5CTL0 &= ~LOCKLPM5; // Enable the GPIO pins // Configure and initialize LEDs P1DIR |= redLED; // Direct pin as output P9DIR |= greenLED; // Direct pin as output...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT