Hello Devs!
I am a student of mechatronics engineering, and I love embedded systems. Although I am a learner, I've seen multiple projects of my seniors, and I am excited to start practicing in this field. here is my first project in Arduino IDE.
This project offers a substantial learning opportunity for professionals in the area by fusing physical hardware and C++ programming to enable the management of a variety of household appliances.
The project's main goal is to use an Arduino board to create a simple home automation system. The goal of this system is to make it possible to operate LED lights, a temperature sensor to monitor the surrounding environment, and a servo motor that doubles as a door lock. Control can be applied manually using traditional switches or using a smartphone application. The usage of C++ is required for the implementation. This is my code:
`
include
include
define DHTPIN 7
define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
Servo myServo;
int ledPin = 13;
int buttonPin1 = 2;
int buttonPin2 = 3;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
myServo.attach(9);
Serial.begin(9600);
dht.begin();
}
void loop() {
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
if (digitalRead(buttonPin1) == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
// Check button state for Servo motor (Door lock control)
if (digitalRead(buttonPin2) == HIGH) {
myServo.write(90);
} else {
myServo.write(0); }
delay(200);
}`
To enable the remote control of many devices, a Bluetooth terminal application has been utilized to transmit orders to an Arduino board over Bluetooth technology.
For instance, the command 'L' turns on an LED light, while the command 'D' starts a servo motor to unlock a door. The system has been configured to react to particular orders. It is expected that future advancements will involve the development of a custom application using MIT App Inventor with the goal of enhancing the system control user interface.
This project has provided significant educational benefits, greatly enhancing the understanding of Arduino hardware and C++ programming languages. The integration of sensors, motors, and Bluetooth control mechanisms has opened up numerous possibilities for further exploration. As progress continues, it is expected that the system will be refined and augmented with additional features.
Input from peers and experts in the domain is encouraged, as is the sharing of experiences related to similar home automation projects that incorporate Arduino or C++. Such collaborative discussions are intended to promote knowledge sharing and foster collective expertise in the field.
Top comments (0)