EA CA2

This project is useful as Singapore is a humid and hot country. This allows the user to have a peaceful night of sleep. User does not have to wake up to turn off the fan when is too hot and switch off the fan when is too cold.
The skill level for the project is soldering and Arduino programming

Things you need:

  • 1 Breadboard,
  • 1 2N2222 transistor
  • 1 220 Ohms Resistor
  • 1 1N4001 diode
  • Jumper Wire
  • 1 D.C motor
  • 1.Speeeduino
  • 1.battery holder
  • 4 2A battery
  • 1 stripBoard
  • 1.Servor Motor

Tools and software

  • Soldering tools
  • Arduino

Step 1: Build the Schematic Diagram on Breadboard

Follow the schematic Diagram given.

Firstly connect the vout of LM35 to A0. Connect GND of LM35 to Gnd.COnnectt 5v to 5v of the Arduino. Secondly, Connect the 220-ohm resistor to PWM pin 9 of Arduino. The resistor is connected to the Base of 2n222 transistor Thirdly, The Emitter of the transistor is connected to the ground. The collector is connected to the diode. The fourth step is to connect the diode in parallel to the d.c motor. The d.c motor and diode are connected to the 6v power supply. The fifth step, the power supply is connected to the ground The sixth step is to connect PWM 3 pin to pin2 of the Servo. Pin 1 is connected to 5v and pin 3 is connected to the ground.

Explanation

The diode is used to prevent flyback from the D.C motor, hence is connected parallel to the motor. The D.C motor is connected to the PWM 9 of the Arduino. The transistor is used to control the D.C motor. The LM 35 is connected to A0. A0 is an analog pin

Step 2: Coding

Coding to be done in Arduino

#include
float temp;

int tempPin = A0; //arduino pin used for temperature sensor

int tempMin = 30 ; // the temperature to start the buzzer

int tempMax = 70;

int fan = 9; // the pin where fan is connected

int fanSpeed = 0; Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {

pinMode(fan, OUTPUT);s

pinMode(tempPin, INPUT); myservo.attach(3);

Serial.begin(9600);

}

void loop() {

temp = analogRead(tempPin);

temp = (temp *5.0*100.0)/1024.0; //calculate the temperature in Celsius

Serial.println(temp);

delay(1000); // delay in between reads for stability

if(temp < tempMin) { // if temp is lower than minimum temp

fanSpeed = 0; // fan is not spinning

digitalWrite(fan, LOW);

}

if((temp >= tempMin) && (temp <= tempMax)){ //if temperature is higher than the minimum range

fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan

analogWrite(fan, 255); // spin the fan at the fanSpeed speed

for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position

}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(15); // waits 15ms for the servo to reach the position
}

}

}

Step 3: ​Final Product

Solder the components on to the stripboards using the soldering tools. The project is done :)

Share

    Recommendations

    • Planter Challenge

      Planter Challenge
    • Games Contest

      Games Contest
    • Growing Beyond Earth Maker Contest

      Growing Beyond Earth Maker Contest

    Discussions