Control DC Motor using Temperature sensor
Description:
The DC motor is controlled through the Temperature Sensor using the following criteria.
- When the Temperature reading is greater than 40' C, the Motor is ON and the Red LED is turned ON.
- When the Temperature reading is less than 40' C, the Motor is OFF and the Green LED is turned ON.
Working Demo:
Components required:
- Arduino UNO
- DC motor
- Motor Driver [L293D]
- Battery [9V]
- Temperature Sensor [TMP36]
Schematic diagram:
Code:
int celsius = 0;int fahrenheit = 0;
int Ena=7;
void setup()
{
Serial.begin(9600);
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
analogWrite(Ena,255);
}
void loop()
{
celsius = map(((analogRead(A0))), 0, 1023, 30, 70);
fahrenheit = ((celsius * 9) / 5 + 32);
Serial.print(celsius);
Serial.print(" C, ");
Serial.print(fahrenheit);
Serial.println(" F");
if (celsius < 40) {
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(8, LOW);
digitalWrite(13, LOW);
}
if (celsius > 40)
{
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(13,LOW);
digitalWrite(8, HIGH);
}
delay(10);
}
motor is not showing rpm
ReplyDeleteDo you have any ideas if add esp8266 ?
ReplyDelete