Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Importance and Utility of the Serial Monitor
The Serial Monitor is a crucial tool in Arduino programming as it allows communication between the Arduino board and the computer. It provides a way to send and receive data, making it easier to debug and monitor the behavior of the Arduino program. By displaying data in real-time, the Serial Monitor helps in understanding the program's execution and aids in troubleshooting any issues that may arise.
Project: Creating a Temperature and Humidity Monitor
In this project, we will create a temperature and humidity monitor using an Arduino board and a DHT11 sensor. The objective is to read the temperature and humidity values from the sensor and display them on the Serial Monitor. This project can be useful in various applications such as home automation, greenhouse monitoring, and weather stations.
List of components:
Examples:
Example 1: Reading Temperature and Humidity Values
#include <dht.h>
dht DHT;
#define DHT11_PIN 7
void setup() {
Serial.begin(9600);
}
void loop() {
int chk = DHT.read11(DHT11_PIN);
Serial.print("Temperature: ");
Serial.print(DHT.temperature);
Serial.print(" °C\t");
Serial.print("Humidity: ");
Serial.print(DHT.humidity);
Serial.println(" %");
delay(2000);
}
Explanation:
Example 2: Sending Commands to Arduino via Serial Monitor
int ledPin = 13;
char command;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if (Serial.available()) {
command = Serial.read();
if (command == 'H') {
digitalWrite(ledPin, HIGH);
Serial.println("LED turned ON");
} else if (command == 'L') {
digitalWrite(ledPin, LOW);
Serial.println("LED turned OFF");
}
}
}
Explanation: