controlling a dc motor with a thermistor? + more?


hey guys, im new user arduino , matter kind of programming getting grips it.

for small uni project creating thermostat system monitors temperature, , various light levels , prints them on lcd.  now that, have coded , working fine, want attatch motor circuit open , close window when temperature rises high etc.

i have dc motor connected using l293d chip allow change direction.  i have code allow change direction when temp @ point, major issue motor carries on turning after temperature has gone past turning point.

this burn out motor/ruin if window opens amount etc!

anyway, part of code controls motor left , right via temperature level. uses 'if' funtion.

code: [select]
  if (analogread(0) > 930) {
 motor_left();
 delay(1000);
 motor_stop();}
   else if (analogread(0) <= 930) {
 motor_right();
 delay(1000);
 motor_stop();}


so asking, if knows how put limit on how long motor can turn on in direction.  this constrain opening window far, , same closing it.

i hope have explained enough...

thanks

the trick motor turn once when reading passes threshold. keep boolean variable indicates if window open or closed , change state of motor if reading on threshold , window closed. move motor , change variable state.
do same on way down.


Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > controlling a dc motor with a thermistor? + more?


arduino

Comments

Popular posts from this blog

CAN'T INSTALL MAMBELFISH 1.5 FROM DIRECTORY - Joomla! Forum - community, help and support

error: expected initializer before 'void'

CPU load monitoring using GPIO and leds - Raspberry Pi Forums