Croduino temperature-controlled 12V fan with simultaneous multi-output control

Customer:

I need help writing code and a schematic for controlling the speed of a motor powered by 12V, where the speed is affected by temperature. As temperature increases, motor speed increases.

Original message (Croatian)

Molim pomoc u pisanju coda i sheme a to je: kako da spojim i napisem code za upravljanje brzine motora koji se napaja sa 12V a na ciju brzinu utice tempetatura? Kako temperatura raste tako raste i brzina motora.

Hvala

[name removed]

Originally submitted via email support on 24 March 2016. Migrated to the forum for community visibility.

Soldered Support:

Which motor are you controlling? Generally you can use the “map” function. https://www.arduino.cc/en/Reference/Map

Original message (Croatian)

kojim motorom upravljate?
Generalno možete koristiti funkciju “map”. https://www.arduino.cc/en/Reference/Map

Customer:

Specifically, it will be a fan from a car.

Original message (Croatian)

Tacnije bit ce ventilator iz auta

[name removed]

“Tiho [name removed] (Support: e-radionica.com)” je napisao(la):

Soldered Support:

I assume it’s a 5V fan. You can use this code in void loop():

int brzinaVentilatora = map(temperatura, 15, 35, 0, 255);
analogWrite(pinVentilatora, brzinaVentilatora);

where:

  • brzinaVentilatora - the speed at which the fan will rotate (0-255, equivalent to 0V-5V)
  • temperatura - the temperature read from the sensor
  • pinVentilatora - PWM pin of Arduino (if you are using Croduino these are: 3,5,6,9,10,11) → connected to the fan’s positive pole (red wire)

Explanation:
The speed will increase proportionally with temperature increase. So at temperature 15, the speed will be 0, while at temperature 35 the speed will be 255 (maximum). You can set the temperature range as needed. Be careful about what happens when temperature falls below 15 or exceeds 35. You can solve this problem this way:

// if temperature is less than 15, temperature becomes 15
if(temperatura < 15) temperatura = 15;
if(temperatura > 35) temperatura = 35;
Original message (Croatian)

pretpostavljam da je 5V ventilator.
Možete koristiti ovaj kod u void loop():
int brzinaVentilatora = map(temperatura, 15, 35, 0, 255);

analogWrite(pinVentilatora, brzinaVentilatora);
gdje je:
brzinaVentilatora - brzina kojom će se ventilator okretati (0-255, odnosno 0V-5V)

temperatura - ocitana temperatura sa senzora

pinVentilatora - PWM pin Arduina (ako koristite Croduino to su: 3,5,6,9,10,11) → plus pol ventilatora(crvena zica)
objašnjenje:
brzina će se povećavati proporcionalno s povećanjem temperature. Tako da pri temperaturi 15, brzina će biti 0, dok pri temperaturi 35 brzina će biti 255 (maksimalna). Raspon temperature možete sami postaviti kako Vam odgovara. Pripazite što će se dogoditi kada temperatura padne ispod 15, odnosno iznad 35. Problem mozete rješiti na ovaj način:
// ako je temperatura manja od 15, temperatura je 15.

if( temperatura 35 ) temperatura = 35;

Customer:

The fan runs on 12V, it’s a fan from a car.

Original message (Croatian)

Ventilator radi na 12V, ventilator je iz automobila.

Hvala

[name removed]

“Tiho [name removed] (Support: e-radionica.com)” je napisao(la):

Soldered Support:

Then just insert something like this in between: http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/

Original message (Croatian)

Onda samo između ubaciti nešto ovako:
http://bildr.org/2011/03/high-power-control-with-arduino-and-tip120/

Customer:

One more question: is it possible to run two different loops at the same time on two different outputs? For example, control one component on one output with one interval and another component on another output with a different interval?

Original message (Croatian)

Hvala na pomoci. Jos me jedno interesuje a to je , da li je moguce u istom vremenu obavljat dva razlicita loop-a na dva razlicita izlaza?? Npr : da se na jednom izlazu upravlja jednom komponentom sa jednim intervalom a na drugom drugom komponentom sa drugim intervalom???

Hvala

[name removed]

“Tiho [name removed] (Support: e-radionica.com)” je napisao(la):

Soldered Support:

It’s possible. Just write them one after another inside the loop (and try to avoid using delay()) and they will execute simultaneously.

Original message (Croatian)

moguće je. Samo ih unutar loopa napišite jedan za drugim(i probajte izbjeći korištenje delay-a) pa će se oni izvesti istovremeno.