Go Down

Topic: How to program buttons for 1602 lcd1602 keypad shield (Read 1 time) previous topic - next topic

Dear all,
because my poor knowledgment I need some help for assign someaction to some buttons for following sketch.
Of course I'll pay for that job.

Actual Hardware:

-Arduino Uno
- LCD Keypad shield 1602 (with 6 butttons)(8, 9, 4, 5, 6, 7)
- Reed switch connected to digital pin 2
- Some wiring
- 10kohm resistance (pullup) to ground

Purpose of my sketch:  pulse counting (rpm) of a wheel with an LCD 1602 display with keypad and connected to an excel spreadsheet.
Actual state: sketch who works perfectly and fulfills my needs ….but

These are my needs:

1)I would like to configure 2 buttons of the keypad for adding/substracting 1 unit on every push of each button

Button UP:  it has to do following calibr = calibr + 0.001;
On every press the new value must appear on the screen

Button DOWN: calibr = calibr - 0.001;
On every press the new value must appear on the screen

Button LEFT = (store "pulsecounter" value in eeprom). By reconnecting or resetting, the value of "pulsecounter" should restart counting from saved value

2) I would like to calculate the speed  ( rev. por second) every time "pulsecounter" reaches 10,20,30.. ( every 10 pulses) and to show it on display (instead actual Time  mm:ss)

3) I also would like to fade the backlight through the other 2 free buttons or a menu on the lcd shield.

I'll pay ( payment method as you prefere) for every step you can solve.If you think you're able to solve one of my needs, please feel free to contact me here..or better by mail
efervescencio at hotmail dot com.

thanks to all

Code: [Select]
/*  Pulse counter with 1602 lcd1602 keypad shield*/

#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

const float calibr = 1.673;   // calibration factor
const int  sensor = 2;   

long pulsecounter = 0;   // pulse counter
int actualcounter = 0;         // actual state of counter
int previouscounter= 0;     // previous state of counter
int second = 0;
int minute = 0;
int msg=0;
float meters = 0.00;
long lastEvent = 0;  // time for last pulse
int interval = 30;    // debounce time for ignore double pressing

void setup()
  pinMode(sensor, INPUT);    // initializing sensor as input
  lcd.begin(16, 2); // lcd library starting
  if(msg==0)       //welcome message show only once
       lcd.print("Reset OK");
       msg = 1;

void loop()
  actualcounter= digitalRead(sensor); // digital read of sensor state
if (actualcounter != previouscounter) // compares actual state with it previous

if (actualcounter == HIGH && millis() - lastEvent > interval)
// ignores a second press if it's too close to the previous
  lastEvent = millis();  // writes time for last valid pulse/press
      meters= counter * calibr / 1000 ;
  lcd.setCursor(0,1); //  cursor on second line "1" and  0 spaces
  lcd.setCursor(4,1) ;
  actualcounter = digitalRead(sensor); 
  minute = millis() / 60000 ;
  second = (millis() / 1000 ) - ( minute* 60 ) ;
      if (minute < 10) lcd.print("0");    // if minutes <10 it writes a "0" before
       lcd.print(minute);                 // without this code it would be: H:M:S  (1:M:S)
      if (second < 10) lcd.print("0");  // same reason as above

  previouscounter = actualcounter;
// saves the actual state as the previous one through the loop     

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131