Help needed printing to LCD GDM1602K Xiamen Ocular

Hello guys,

I am trying to print rpm value that inputs as a pulse signal on analog pin 5.

The program:

#include <DateTime.h>
#include <LiquidCrystal.h>

int resetPin = 3; // pin 3 resets the time
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;

//create object to control an LCD GMD1602K.
LiquidCrystal lcd(12, 11, 2, 7, 8, 9, 10);

void setup(){
digitalWrite(resetPin,HIGH); // this line enables pull-up
pinMode(13,OUTPUT); // flash the LED each second
pinMode(resetPin, INPUT); // a button on this pin resets the time
DateTime.sync( 0 ); // set time to zero

}

/* ------Counts & prints rpm (adapted from Arduino Forum) ---------/
if (rpmcount >= 20) { //Update RPM every 20 counts, increase this for better RPM resolution,
//decrease for faster update
rpm = 30
1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
lcd.setCursor(0,0);
lcd.print(“rpm”);
lcd.print(" “);
lcd.setCursor(4,0);
lcd.print(rpm);
lcd.print(” ");

void rpm_fun()
{
rpmcount++;
//Each rotation, this interrupt function is run twice
}

Sympthoms:

No result is printed, even the label “rpm” is not printed.

Any solutions ?

Thank you.

Old Beaver

Does "rpmcount" ever exceed 19? You're also missing a "}" somewhere before "void rpm_fun".

Some code is missing from the sketch you posted. rpm_fun is never called. Try this to see if you get anything on the lcd. And add in the code that wull call rpm_fun

#include <DateTime.h>
#include <LiquidCrystal.h>

int resetPin = 3; // pin 3 resets the time
volatile byte rpmcount =20;
 unsigned int rpm;
 unsigned long timeold;

//create object to control an LCD GMD1602K.
LiquidCrystal lcd(12, 11, 2, 7, 8, 9, 10);

void setup()
{

 pinMode(13,OUTPUT);             // flash the LED each second
 pinMode(resetPin, INPUT);       // a button on this pin resets the time
 digitalWrite(resetPin,HIGH);    // this line enables pull-up   
 DateTime.sync( 0 );             // set time to zero
 
}

void loop()
{
/* ------Counts & prints rpm (adapted  from Arduino Forum) ---------*/
 if (rpmcount >= 20) {           //Update RPM every 20 counts, increase this for better RPM resolution,
    //decrease for faster update
    rpm = 30*1000/(millis() - timeold)*rpmcount;
    timeold = millis();
    rpmcount = 0;
    lcd.setCursor(0,0);
    lcd.print("rpm");
    lcd.print(" ");
    lcd.setCursor(4,0);
    lcd.print(rpm); 
    lcd.print(" ");

 }
}
 
void rpm_fun()
{
  rpmcount++;
  //Each rotation, this interrupt function is run twice
}

Dear Mem,

This is the contents of the missing function:

void rpm_fun() {

//Each rotation, this interrupt //function is run twice, so take //that into consideration for //calculating RPM //Update count rpmcount++;

//Toggle status LED if (status == LOW) { status = HIGH; } else { status = LOW; } digitalWrite(statusPin, status); }

This function is called only once in Void Setup as follows:

attachInterrupt(0, rpm_fun, FALLING);

I missed it, so I will check myself too. :-?

Thank you,

Old Beaver

AWOL,

Tks, I will check that too.

Old Beaver

Thank you folks !! :)

The program is workin OK.

Tomorrow I will test with real car inputs.

Good programming,

Old Beaver