Smart fan
Smart fan
Smart fan is advice which used ultrasonic sensor to know any person has enter to the room then the fan is work automatic.
The input used are:
Ultrasonic sensor
Switch
The output used are:
Fan
LED light
I used Arduino IDE to write the code.
I used ultrasonic, switch, LED, fan, and breadboard.
I used Arduino as a brain.
Arduino IDE
Tools
Cardboard
I used Arduino IDE to write the code on which the DC fan works when an object less than a distance of 50 cm far is entered in front of the ultrasonic sensor with a click of the switch. Also, the LED light works with the fan.
Explain the code:
First: define numbers, integers, and variables.
Second: make void setup to define input and outputs (switch and echo pin of ultrasonic are inputs, while motor, LED, and trig pin of ultrasonic sensor are outputs). Also, starts serial communication.
Third: Make void loop: define equation and distances of ultrasonic sensor which can sense when thing approximate distance 50 cm or less. If ultrasonic sonic sense and switch on the LED and motor on. Else LED off and motor off.
Arduino code:
// defines pins numbers
const int trigPin = 9;
const int echoPin = 10;
// defines variables
long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
pinMode(7, INPUT_PULLUP); //switch
pinMode(2, OUTPUT); //motor
pinMode(8, OUTPUT); //LED
Serial.begin(9600); // Starts the serial communication
}
void loop() {
int f = digitalRead(7);
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
if (distance < 50 && f == HIGH) {
digitalWrite(8, HIGH);
digitalWrite(2, HIGH);
}
else {
digitalWrite(8, LOW);
digitalWrite(2, LOW);
}
}
Wiring of the system in TinkerCAD
Connect Ultrasonic sensor to the Arduino
Connect switch to thr Arduino
Connect the fan to the Arduino
Connect the LED to Arduino
Snapping during cardboard
Snapping during cardboard
Project cardboard
During this week, I worked with the team which made a great effort and we helped each other. We Build a Smart Home System using Arduino.
The DC fan and DC lamp working in two modes:
Manual mode using pushbuttons.
Automatic mode using DHT and LDR sensors.
When I got stuck, I asked Ahmed or Farida to help me.
Challenge
When I did my assignment, I faced a challenge during connecting the switch to Arduino. I forgot to connect the put PULLUP input in Arduino code. So after checking the problem, I write INPUT_PULLUP to the code of the Arduino.
We can avoid this problem when we do the assignment.
Focusing on how to combine multi sensors and multi outputs to the Arduino are the skills and knowledge that I have acquired this week in my final project.
The coolest thing I have learned this week is combining multi-inputs and multi outputs to the Arduino.
Revision jumpers and trouble-shooting in general are something that I will never forget from this week.