LCD Display Random Characters 16x2 output variable data (data,DEC)


hello,
i have made successful tachometer measuring erector set motor's speed (rpm) using ir led , ir detector diode. original program set display data i.e. rpm via serial monitor.  i have been trying hours alter code display on 16x2 lcd display instead or better yet both.  all "lcd ready..." displayed setup sequence random jumbled numbers measurements.  these random characters change speed changes.  serial monitor still displays correct information.  can data not displayed on both simultaneously?  i know simple.  serial.println(rpm,dec); print serial monitor , lcd.print(rpm,dec); should print exact data lcd correct?  (with delay clear lcd , repeat).  i have used lcd display text in quotations lcd.print("you're loony");  but never variable changing data.  here edited tachometer code have far:

code: [select]
/*
* optical tachometer
*

* ir led connected pin 13 , ran continually. status led connected
* pin 12. pin 2 (interrupt 0) connected across ir detector.
*
*
*/
#include <liquidcrystal.h>

liquidcrystal lcd(12, 11, 5, 4, 3, 1);

int ledpin = 13;                // ir led connected digital pin 13
int statuspin = 8;             // led connected digital pin 12

volatile byte rpmcount;
volatile int status;

unsigned int rpm;

unsigned long timeold;

void rpm_fun()
{
  //each rotation, interrupt function run twice, take consideration
  //calculating rpm
  //update count
     rpmcount++;
     
  //toggle status led  
  if (status == low) {
    status = high;
  } else {
    status = low;
  }
  digitalwrite(statuspin, status);
}

void setup()
{
  lcd.begin(16,2);
  lcd.clear();
  lcd.setcursor(0,0);
  lcd.print("lcd ready...");
  delay(1000);
  lcd.clear();
 
  serial.begin(9600);
  serial.println("serial monitor ready...");
  delay(1000);
  //interrupt 0 digital pin 2, ir detector connected
  //triggers on falling (change high low)
  attachinterrupt(0, rpm_fun, falling);
 
  //turn on ir led
  pinmode(ledpin, output);
  digitalwrite(ledpin, high);
 
  //use statuspin flash along interrupts
  pinmode(statuspin, output);

  rpmcount = 0;
  rpm = 0;
  timeold = 0;
  status = low;
}

void loop()
{

  //update rpm every second
  delay(1000);
  //don't process interrupts during calculations
  detachinterrupt(0);
  //note 60*1000/(millis() - timeold)*rpmcount if interrupt
  //happened once per revolution instead of twice. other multiples used
  //for multi-bladed propellers or fans
  rpm = 30*1000/(millis() - timeold)*rpmcount;
  timeold = millis();
  rpmcount = 0;
 
    //write out serial port
  serial.println(rpm,dec);
       //write lcd too
   lcd.clear();
    lcd.print(rpm,dec);
    delay(10);
    lcd.clear();
   


 
  //restart interrupt processing
  attachinterrupt(0, rpm_fun, falling);

 }

look code in loop , think how updating display.

you wait long time (1 second)
you stuff , calculate stuff,
clear display
write display
wait 10 milliseconds
clear display.

then repeat.

so if @ that, majority of time display will
be cleared because clear after wrote it,
then delay long time (1 second) when display cleared.
you aren't going see doing that.
the human eye needs close 16ms see things without flicker.
also, lcd panel needs 15 20ms change liquid molecules darken
the pixels.

think moment, solution quite simple.
hint: display should contain want see when long
delay happening.

--- bill






Arduino Forum > Using Arduino > Displays > LCD Display Random Characters 16x2 output variable data (data,DEC)


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support