Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Automatic control systems are integral to modern engineering, enabling devices to operate autonomously and efficiently. In the Arduino environment, automatic control can be implemented to manage various systems, such as temperature regulation, motor speed control, or lighting systems. This article will guide you through creating a simple automatic control system using an Arduino board.
Examples:
Let's consider a practical example of controlling the temperature of a room using an Arduino, a temperature sensor, and a fan. The goal is to maintain the room temperature within a specific range automatically.
Components Required:
Step-by-Step Instructions:
Set Up the Hardware:
Connect the DHT22 sensor to the Arduino:
Connect the Relay Module to the Arduino:
Connect the DC Fan to the Relay Module.
Install the Required Libraries:
You need to install the DHT sensor library. You can do this via the Arduino IDE:
Write the Arduino Code:
#include <DHT.h>
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)
#define RELAY_PIN 8 // Pin where the relay is connected
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(RELAY_PIN, OUTPUT);
}
void loop() {
float temperature = dht.readTemperature();
if (isnan(temperature)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
// Automatic control logic
if (temperature > 25.0) {
digitalWrite(RELAY_PIN, HIGH); // Turn on the fan
Serial.println("Fan ON");
} else {
digitalWrite(RELAY_PIN, LOW); // Turn off the fan
Serial.println("Fan OFF");
}
delay(2000); // Wait a few seconds between readings
}
Upload the Code:
Test the System:
This simple automatic control system demonstrates how Arduino can be used to create autonomous systems that respond to environmental changes.