Temperature Sensor To control Servo Motor

Temperature Sensor To control Servo Motor

In this arduino project, We use a temperature sensor LM35, to control the speed of the Servo motor.

  • 12,202 views
  • 2 comments
  • 17 respects

Components and supplies

About this project

In the project, we use the arduino UNO and connect it to the temperature sensor. The three pins of the LM35 temperature sensor are connected to the input pin A0,+5V and GND respectively. The temperature sensor senses the temperature outside and updates it on the serial monitor. The Servo motor is connected to the pulse width modulation PIN 6. It controls the speed of the Motor with respect to the temperature outside. As the temperature increases, the speed of the motor increases.

It can be used in a large project like a smart home.

Diode 1N4007 is connected in parallel to the motor such that moving current doesn't cause damage to the arduino kit when in opposite direction.

NPN transistor BC547 is connected along with a 1k resistor to the PWM PIN 6 of the arduino UNO.

External 9 or 12 V battery source is connected to the motor and grounded with the emitter of the transistor.

Code

temperature controlled servo motorArduino
float temp;

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

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

int tempMax = 70;

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

int fanSpeed = 0;

void setup() {

pinMode(fan, OUTPUT);

pinMode(tempPin, INPUT);

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, fanSpeed); // spin the fan at the fanSpeed speed

}

}

Schematics

Schematic Diagram
Fnxgm38ia0wfw69 medium l41ivikp6t

Comments

Similar projects you might like

Arduino/Android - BLUETOOTH Multi Servo Motor Control

Project tutorial by Danny van den Brande

  • 13,195 views
  • 8 comments
  • 18 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,594 views
  • 5 comments
  • 17 respects

Using Serial Monitor to Control Servo Motor

Project tutorial by Kub_Luk

  • 5,228 views
  • 10 comments
  • 33 respects

Control the Speed of Brushless DC Motor Using Bluetooth

Project tutorial by mohitmehlawat

  • 3,500 views
  • 0 comments
  • 13 respects

Control Speed and Direction of Motor

Project in progress by ahmed soliman

  • 13,243 views
  • 3 comments
  • 19 respects
Add projectSign up / Login