Failed Attempt to make A temperature Controlled Fan using Arduino

Hello there,

I hope this is the appropriate section for this topic, If not I’m sorry since I’m new here :slight_smile:

I’ve been trying to simulate a temperature controlled fan using Arduino Uno Board on Proteus software, I’ve already done that using PIC before but I’m trying to do it in Arduino now. It’s supposed to turn on the fan when it reaches 20 Celsius and display a reading & a message on the LCD, instead it either turns off the fan completely or on all the time no matter what temperature there is ! I tried changing the circuit connection (attached in this post), used a diode instead of a l293d IC but nothing changed. I have attempted many code formations but none of them seems to fix this(they are between comments below since I don’t know which one might need a slight modification). So I’m a little confused whether the problem lies in coding or in the circuit diagram or even both ! Any help figuring out what the problem is would be much appreciated, thanks ! :slight_smile:

#include<LiquidCrystal.h>
int A=0;
int B;
int sensorpin=A0;
int fan= 13; 
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
              lcd.begin(16, 2);
              lcd.print("Temperature Fan");
              pinMode(fan,OUTPUT);
             }

void loop() {
              A= analogRead(sensorpin); // get the temprature
              B= (A/2);
              lcd.setCursor(0,0);
              lcd.print("Temperature:");
              lcd.setCursor(0,1);
              lcd.print(B);
              lcd.print("C");
              /*for (B=19; B<255; B++)
              {
                digitalWrite(fan, HIGH);
                lcd.setCursor(0,0);
                lcd.print("FAN IS ON");
              }*/
              /*if(B < 20 )   // if temprature is lower than minimum temp
                {
                analogWrite(fan, LOW);
                lcd.setCursor(0,0);
                lcd.print("FAN IS OFF");
                }*/
               if(B == 20 )   // if temprature is at than minimum temp
                {
                digitalWrite(fan, HIGH);
                lcd.setCursor(0,0);
                lcd.print("FAN IS ON");
                }
              
             /* if(B >= 20)
                {
                digitalWrite(fan, HIGH);
                lcd.setCursor(0,0);
                lcd.print("FAN IS ON");
                }
               else
                {
                digitalWrite(fan, LOW);
                lcd.setCursor(0,0);
                lcd.print("FAN IS OFF");
                }*/
              
            }

If I understand your question correctly, you are running the code in Proteus simulation software?

If so, then the simulator isn’t a product of Arduino.cc and I would suggest directing your question towards the people who wrote the software.