How do you use a LCD screen and program it for fan speed and display rpm?

I am putting together a shopping list for an arduino. I would like to have an lcd screen that is some how connected to a dc fan.

How exactly do you have a screen showing "Speed 10%" then when you press a small up button it then changes to "speed 20%" etc then have like a enter button to select the speed. And as soon as you hit that enter button the fan speed will increase to what ever speed you select.

How is that done? Is one particular brand/type of LCD better than others? I read that serial LCD is easier to use as it only have 4 wires.

Then also if I wanted a temperature sensor to display the temp on the lcd is that hard to do. Can you set up pages, so like show fan speed on page 1, temp on page 2, and on page 3 the motor speed adjustment selector.

Peter

Hi…

I’m no expert on this, but I guess it’s true to say that you don’t connect the LCD to the fan, but rather connect both to the Ardy 8). Then your sketch displays a message, you react and press a button, and the Ardy reacts to the button and controls the fan.

The below sketch is from the LCD library and I have a tiny modification in it to light up one LED when one of the buttons is pushed and off again with another button. I have one of these LCD shields.

In the sketch you can see how to write to the screen and read a button and react to it. Then it’s a matter of having the sketch control the PWM output of a pin to control the motor speed, thru the base of a transistor with the appropriate diode protection as described about half way down this page

//Sample using LiquidCrystal library
#include <LiquidCrystal.h>
 
/*******************************************************
 
This program will test the LCD panel and the buttons
Mark Bramwell, July 2010
Jim May 2012... also "up" button lights up led on pin 2
 
********************************************************/

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);  //or whatever pins the LCD needs
 
// define some values used by the panel and buttons
int lcd_key     = 0;
int adc_key_in  = 0;
#define btnRIGHT  0
#define btnUP     1
#define btnDOWN   2
#define btnLEFT   3
#define btnSELECT 4
#define btnNONE   5
 
// read the buttons
int read_LCD_buttons()
{
 adc_key_in = analogRead(0);      // read the value
 // the key produces an analog reading
 // buttons when read are centered approx at these values: 0, 144, 329, 504, 741
// and with no button pressed 1023
// but check what your LCD produces with the code marked ******* below
 
 // we add approx 50 to those values and check to see if we are close
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
 if (adc_key_in < 50)   return btnRIGHT;  
 if (adc_key_in < 195)  return btnUP; 
 if (adc_key_in < 380)  return btnDOWN; 
 if (adc_key_in < 555)  return btnLEFT; 
 if (adc_key_in < 790)  return btnSELECT;   
 return btnNONE;  // when all others fail, return this...
}
 
void setup()
{
  // initialize the digital pin2 as an output and force it low
  pinMode(2, OUTPUT); 
  digitalWrite(2, LOW);
  // then do lcd stuff...
 lcd.begin(16, 2);              // start the library
 lcd.setCursor(0,0);
 lcd.print("Push a button..."); // print a simple message
}
  
void loop()
{
  //led on 2 test
  //digitalWrite(2, HIGH);
 lcd.setCursor(12,1);            // move cursor to second line "1" and 9 spaces over
 lcd.print(millis()/1000);      // display seconds elapsed since power-up
 
 
 
 lcd_key = read_LCD_buttons();  // read the buttons
 lcd.setCursor(7,1);            //print the raw value *********
 lcd.print("    ");             //first clearing cos they not all same length so last number might show from under
 lcd.setCursor(7,1);  
 lcd.print(adc_key_in);          
 
 lcd.setCursor(0,1);            // move to the begining of the second line
 switch (lcd_key)               // depending on which button was pushed, we perform an action
 {
   case btnRIGHT:
     {
     lcd.print("RIGHT ");
     break;
     }
   case btnLEFT:
     {
     lcd.print("LEFT   ");
     break;
     }
   case btnUP:
     {
     lcd.print("UP2LED");
     digitalWrite(2, HIGH);  //led on
     break;
     }
   case btnDOWN:
     {
     lcd.print("DOWN  ");
     digitalWrite(2, LOW); //led off
     break;
     }
   case btnSELECT:
     {
     lcd.print("SELECT");
     break;
     }
     case btnNONE:
     {
     //digitalWrite(2, LOW);  //make sure led is off again
     lcd.print("NONE  ");
     break;
     }
 }
 
}

apples: Is one particular brand/type of LCD better than others? I read that serial LCD is easier to use as it only have 4 wires.

Have a look here http://arduino.cc/en/Tutorial/LiquidCrystal about suitable LCD types. Main thing is the LCD uses a 'Hitachi HD44780' compatible control syntax. If you want buttons as well then consider this shield http://www.hobbytronics.co.uk/lcd/arduino-lcd-keypad-shield Temperature is no problem, just get a device to suit your needs. Maybe something here http://www.hobbytronics.co.uk/index.php?route=product/search&keyword=temperature What dc fan are you using because it's a sure bet you cannot connect it directly to the arduino so will need some form of driver for it.

If you are using computer fans, there are some 3 and 4 wire ones that have a "tach" wire that you can use to determine RPM.

wizdum: If you are using computer fans, there are some 3 and 4 wire ones that have a "tach" wire that you can use to determine RPM.

If you want to vary the speed using PWM and measure the RPM using the tacho at the same time, you need a 4-wire computer fan. I've successfully controlled an Arctic F8 PWM fan from an Arduino.