i need help about motors and lcd shield..


code: [select]
#include <liquidcrystal.h>

#include <softwareserial.h>

softwareserial myserial(a3, a4);

liquidcrystal lcd(8, 9, 4, 5, 6, 7);


byte seriala;
int temppin = a1;
int motorpin1 = 3; // pin 2 on l293d ic
int motorpin2 = 4; // pin 7 on l293d ic
int enablepin = 5; // pin 1 on l293d ic
int temp;
int tempmin = 18;
int tempmax = 40;
int fanspeed;
int fanlcd;

void setup() {
    // sets pins outputs:
    pinmode(motorpin1, output);
    pinmode(motorpin2, output);
    pinmode(enablepin, output);
    // sets enablepin high motor can turn on:
    digitalwrite(enablepin, high);
    // sets motorpin2 low:
    digitalwrite(motorpin2, low);
    pinmode(temppin, input);
    lcd.begin(16,2);
    // initialize serial communication @ 9600 bits per second:
    serial.begin(57600);
    myserial.begin(9600);
}

void loop() {
  
if (myserial.available() > 0) {
seriala = myserial.read();
myserial.println(seriala);}

temp = readtemp();     // temperature
   if(temp < tempmin) {   // if temp lower minimum temp
       fanspeed = 0;      // fan not spinning
       digitalwrite(motorpin1, low);
  
   }
  
      switch (seriala) {
    case 1:
      if((temp >= tempmin) && (temp <= tempmax)) {  // if temperature higher minimum temp
       fanspeed = map(temp, tempmin, tempmax, 32, 255); // actual speed of fan
       fanlcd = map(temp, tempmin, tempmax, 0, 100);  // speed of fan display on lcd
       analogwrite(motorpin1, fanspeed);  // spin fan @ fanspeed speed
       digitalwrite(motorpin2, low);
      break;
      }
    case 2:
        digitalwrite(motorpin1, low);
      break;
      }
   lcd.print("temp: ");
   lcd.print(temp);      // display temperature
   lcd.print("c ");
   lcd.setcursor(0,1);   // move cursor next line
   lcd.print("fans: ");
   lcd.print(fanlcd);    // display fan speed
   lcd.print("%");
   delay(200);
   lcd.clear();  
}
  
  int readtemp() {  // temperature , convert celsius
  temp = analogread(temppin);
  return temp * 0.48828125;
}



im on our arduino project there wrong on , don't know what's problem..our arduino project fan system. fan controlled via bluetooth , fan speed controlled temperature sensor has lcd shield display temperature , fanspeed..

the problem is, cant have fan spin when lcd shield attached arduino :(
hope guys can us...

im using 5v fan
lcd shield dfrobot
lm35
hc-05 bluetooth module
and l293d ic

i wonder if liquidcrystal library interfering analogwrite. read timers provide pwm on pairs of pins. may improvement if move lcd other pins - know little library.

...r


Arduino Forum > Using Arduino > Motors, Mechanics, and Power (Moderator: fabioc84) > i need help about motors and lcd shield..


arduino

Comments