I have recently purchased some equipment to create a temperature controlled fan using Arduino. The objective of the project is for the 5 volt fan to shift speeds according the reading of the temperature sensor (LM35) If anyone knows how to write a program to make this task possible can u send me some suggestions? Thank you
this is the code you need, numbers need to be adapted
#define FANPIN 7
void setup()
{
pinMode(FANPIN, OUTPUT);
}
void loop()
{
int t = analogRead(A0); // t == 0..1023, you may covert that (see other post)
if (t > 300) digitalWrite(FANPIN, HIGH);
if (t < 250) digitalWrite(FANPIN, LOW);
}
The fan switches at two temperatures, to prevent continuous on/off switching due to noise..
Succes.
Well, no, shifting speeds requires PWM. You'll need to determine what range of temperatures sets the fan to full off and full on. Then, for the range in between, use a formula to interpolate PWM values for analogWrite.
nella400:
If anyone knows how to write a program to make this task possible can u send me some suggestions?
Wire up the temperature sensor and write some code to read the temperature. Test and debug until it works properly.
Wire up your fan via a suitable driver circuit and write some code to vary the speed. Test and debug until it works properly.
Decide how you want the fan speed to be related to the temperature.
Combine your temperature reading code and your fan controlling code in the same sketch. Use the temperature reading to determine the fan speed according to your algorithm. Test and debug until it works properly.
I've written the program for the temperature sensor(LM35) but when i upload it to the arduino it says NOT SYNC. So my question is how do you get it to sync so that i can read the temperatures on the COM3 screen?
When you say "it says NOT SYNC", what is 'it'? Where does this message appear?
It appear at the bottom the page where you see if you have any errors. it reads "stk500_getsync(): not in sync: resp=0x30". Any help will be highly appreciated
i had that one too, just plug it out of the usb, and try again.. i had to do this 2 times, because i had something connected to the RX while uploading, that solved it without any problem
I will give it another try.