top of page
Writer's pictureSanskruti Ashtikar

How to Create a Temperature Controlled Fan in TinkerCAD

Updated: Nov 26

Introduction


In modern electronics, automatic control systems play a crucial role in managing devices efficiently. A temperature-controlled fan is a practical project that automatically adjusts the fan speed based on the surrounding temperature. This project is ideal for learning about sensors, microcontrollers, and pulse-width modulation (PWM). Using TinkerCAD, we can simulate this project and see how a fan responds to temperature changes. In this article, we will guide you step-by-step to create a temperature-controlled fan using TinkerCAD.





What You Will Need


To create this project, you'll need the following components available in TinkerCAD:

  • Breadboard (Small)

  • Arduino Uno R3

  • NTC Thermistor (Temperature Sensor)

  • DC Motor (Representing the Fan)

  • 10k-ohm resistor

  • NPN Transistor (e.g., 2N2222)

  • Diode (1N4007)

  • 10k-ohm potentiometer (optional, for adjusting temperature threshold)

  • Jumper wires


Step 1: Setting Up the Breadboard and Arduino


  1. Open TinkerCAD: Log in to your TinkerCAD account and go to the "Circuits" section.

  2. Create a New Circuit: Click "Create new Circuit" to open a new workspace where you'll build the temperature-controlled fan circuit.

  3. Place the Breadboard and Arduino: Drag a small breadboard and an Arduino Uno R3 onto the workspace. Position them next to each other for easy connections.


Step 2: Connecting the Thermistor (Temperature Sensor)


  1. Place the Thermistor: Drag the thermistor onto the breadboard. One leg of the thermistor should be connected to the 5V rail, and the other leg should connect to a row in the breadboard.

  2. Add the Resistor: Connect a 10k-ohm resistor from the same row as the thermistor's second leg to the ground (GND) rail. This setup creates a voltage divider that will allow the Arduino to read the temperature.

  3. Connect to Arduino: Connect the junction between the thermistor and the resistor to the analog input pin A0 on the Arduino using a jumper wire.


Step 3: Connecting the Fan (DC Motor)


  1. Place the Transistor: The transistor will act as a switch to control the DC motor. Place the NPN transistor on the breadboard with the flat side facing you. The three pins are emitter, base, and collector (from left to right).

  2. Connect the Motor: Connect one terminal of the DC motor to the 5V rail on the breadboard. Connect the other terminal to the collector pin of the transistor.

  3. Add the Diode: Place the diode across the motor terminals, with the cathode (marked end) connected to the 5V rail. This diode protects the circuit from back EMF generated by the motor.

  4. Connect the Emitter: Connect the emitter pin of the transistor to the ground (GND) rail on the breadboard.

  5. Connect the Base: Use a 10k-ohm resistor to connect the base of the transistor to digital pin 9 on the Arduino. This pin will send the PWM signal to control the motor speed.





Step 4: (Optional) Adding a Potentiometer


  1. Place the Potentiometer: If you want to adjust the temperature threshold at which the fan activates, place a potentiometer on the breadboard.

  2. Connect the Potentiometer: Connect the ends of the potentiometer to the 5V and GND rails. Connect the middle pin (wiper) to analog input pin A1 on the Arduino. This allows you to read and adjust the temperature threshold.


Step 5: Writing the Code


  1. Open the Code Editor: Click on the "Code" button at the top right of the TinkerCAD interface to open the code editor.

  2. Choose Text-Based Coding: Switch to "Text" to write code in Arduino's C/C++ language.


  1. Write the Code:

int tempPin = A0; // Thermistor connected to A0
int motorPin = 9; // Motor connected to pin 9
int potPin = A1;  // Potentiometer connected to A1 (optional)
int threshold = 100; // Default threshold value
void setup() {
  pinMode(motorPin, OUTPUT); // Set motor pin as output
  Serial.begin(9600); // Start serial communication for debugging
}
void loop() {
  int tempValue = analogRead(tempPin); // Read temperature value
  int potValue = analogRead(potPin);   // Read potentiometer value (optional)
  
  // Calculate the temperature (optional: scale this based on your thermistor)
  float voltage = tempValue * (5.0 / 1023.0);
  float tempC = (voltage - 0.5) * 100.0;
  // Set the threshold using potentiometer value (optional)
  threshold = map(potValue, 0, 1023, 50, 150);
  if (tempValue > threshold) {
    // If temperature exceeds threshold, run the fan
    analogWrite(motorPin, map(tempValue, threshold, 1023, 0, 255)); // Adjust fan speed based on temperature
  } else {
    analogWrite(motorPin, 0); // Turn off the fan
  }
  // Debugging output to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(tempC);
  Serial.print(" C, Fan Speed: ");
  Serial.println(analogRead(motorPin));
  delay(500); // Delay to stabilize readings
}
  1. This code reads the temperature value from the thermistor and controls the fan speed based on the temperature. The optional potentiometer allows you to adjust the temperature threshold dynamically.





6: Simulating the Circuit


  1. Start Simulation: Click on the "Start Simulation" button to run your temperature-controlled fan. As the temperature reading (or the value from the thermistor) exceeds the set threshold, the fan (motor) will start running. The higher the temperature, the faster the fan will spin.

  2. Adjusting the Threshold: If you added a potentiometer, you can adjust the temperature threshold by turning the potentiometer knob. This allows you to see how different temperatures affect the fan speed.


Troubleshooting Tips


  • Fan Not Running? Check the transistor connections, ensuring the base is connected to the correct Arduino pin and that the motor is connected properly.

  • Incorrect Temperature Readings? Verify the voltage divider setup with the thermistor and resistor. Also, ensure the analog pin is correctly reading the voltage.

  • Simulation Issues? Ensure all components are placed correctly in TinkerCAD and that there are no loose or incorrect connections.


Conclusion


You've successfully built a temperature-controlled fan using TinkerCAD! This project introduces essential concepts such as reading analog sensor data, controlling outputs with PWM, and using transistors to switch higher current loads. Understanding these principles is crucial for more advanced electronics projects, such as environmental monitoring systems and automated control systems.


TinkerCAD's simulation environment allows you to test and refine your circuit designs without needing physical components, making it an excellent tool for both learning and prototyping.

Keep exploring, experimenting, and innovating as you continue your journey in electronics.


Happy tinkering!


Want us to guide you through your project or make the project for you?





Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



26 views0 comments

Related Posts

See All

Comments


bottom of page