Membuat Kipas Angin Otomatis Arduino

3 min read 5 hours ago
Published on Nov 08, 2024 This response is partially generated with the help of AI. It may contain inaccuracies.

Table of Contents

Introduction

This tutorial guides you through building an automatic fan using Arduino. The project showcases how to control a fan based on environmental conditions, making it a practical application for cooling systems. By following these steps, you'll learn about component integration, coding, and basic electronic circuits.

Step 1: Gather Required Components

To start your project, ensure you have the following components:

  • Arduino board (e.g., Arduino Uno)
  • DC fan
  • Relay module
  • Temperature sensor (e.g., LM35)
  • Jumper wires
  • Breadboard
  • Power supply for the fan

Practical Advice:

  • Choose a fan that operates at a voltage compatible with your relay module.
  • Ensure you have a stable power source for the fan to prevent any interruptions.

Step 2: Set Up the Circuit

Follow these instructions to connect your components properly:

  1. Connect the Temperature Sensor:

    • Connect the VCC pin of the LM35 to the 5V pin of the Arduino.
    • Connect the GND pin to the GND on Arduino.
    • Connect the output pin to an analog input pin (e.g., A0) on the Arduino.
  2. Connect the Relay Module:

    • Connect the control pin of the relay to a digital pin on your Arduino (e.g., pin 7).
    • Connect the VCC pin of the relay to the 5V on the Arduino.
    • Connect the GND pin of the relay to the GND on the Arduino.
    • Connect the fan to the relay (one terminal to the relay output and the other to the power supply).

Practical Advice:

  • Double-check all connections to avoid shorts or incorrect wiring.

Step 3: Write the Arduino Code

Use the following sample code to control the fan based on temperature readings:

#define relayPin 7
#define tempPin A0

void setup() {
  pinMode(relayPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int tempValue = analogRead(tempPin);
  float voltage = tempValue * (5.0 / 1023.0);
  float temperatureC = voltage * 100;

  Serial.print("Temperature: ");
  Serial.println(temperatureC);

  if (temperatureC > 30) { // Adjust threshold as needed
    digitalWrite(relayPin, HIGH); // Turn on fan
  } else {
    digitalWrite(relayPin, LOW); // Turn off fan
  }
  delay(1000); // Read temperature every second
}

Practical Advice:

  • Modify the temperature threshold in the if statement to suit your needs.
  • Use the Serial Monitor to observe temperature readings.

Step 4: Upload Code and Test

  1. Connect your Arduino to your computer using a USB cable.
  2. Open the Arduino IDE and copy the provided code.
  3. Select the correct board and port in the IDE settings.
  4. Click on the upload button to transfer the code to the Arduino.

Common Pitfalls:

  • Ensure the correct board type and port are selected to avoid upload errors.
  • Check for any syntax errors in the code before uploading.

Conclusion

You have now completed your automatic fan project using Arduino. By following these steps, you have learned how to gather components, set up a circuit, write controlling code, and test your project. As next steps, consider experimenting with different sensors or integrating additional features like humidity control. Enjoy your project and explore further possibilities in automation with Arduino!