0% found this document useful (0 votes)
8 views2 pages

Arduino

The document contains an Arduino sketch that reads temperature from an LM35 sensor and controls an LED and a buzzer based on the temperature readings. It sets a green LED for temperatures below 40°C, a red LED and a medium tone for temperatures between 40°C and 55°C, and a red LED with a high tone for temperatures above 55°C. The temperature is printed to the serial monitor in Celsius.

Uploaded by

Abril Michelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Arduino

The document contains an Arduino sketch that reads temperature from an LM35 sensor and controls an LED and a buzzer based on the temperature readings. It sets a green LED for temperatures below 40°C, a red LED and a medium tone for temperatures between 40°C and 55°C, and a red LED with a high tone for temperatures above 55°C. The temperature is printed to the serial monitor in Celsius.

Uploaded by

Abril Michelle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

// Pines

const int pinLM35 = A0;

const int ledVerde = 12;

const int ledRojo = 13;

const int buzzer = 11;

void setup() {

pinMode(ledVerde, OUTPUT);

pinMode(ledRojo, OUTPUT);

pinMode(buzzer, OUTPUT);

[Link](9600);

void loop() {

int valorAnalogico = analogRead(pinLM35);

float voltaje = valorAnalogico * (5.0 / 1023.0);

float temperatura = voltaje * 100.0;

[Link]("Temperatura: ");

[Link](temperatura);

[Link](" °C");

if (temperatura < 40) {

digitalWrite(ledVerde, HIGH);

digitalWrite(ledRojo, LOW);

noTone(buzzer);

} else if (temperatura >= 40 && temperatura <= 55) {


digitalWrite(ledVerde, LOW);

digitalWrite(ledRojo, HIGH);

tone(buzzer, 1000); // tono medio

} else {

digitalWrite(ledVerde, LOW);

digitalWrite(ledRojo, HIGH);

tone(buzzer, 2000); // tono más agudo

delay(500);

You might also like