Read 2 buttons if pushed for 15 sec a function start

Hi

I have a scale with 2 buttons.

  1. Tare
  2. Reset microcontroller

To add an extra function, recalibrate scale, is there a way to read both buttons and if they both are pushed down for 15 sec I can call a recalibrate function?

Important, tare and reset MUST NOT HAPPEN.

Thanks up front.

Yes, absolutely possible.

1 Like

There are button libraries (see IDE library manager) which can provide short press/long press features. You could use a short press on TARE for tare and a long press on TARE for CALIBRATE.

1 Like

by reset button you don't mean the button hardwired to the reset pin? there's nothing that can prevent it from causing a reset

why not just recognize that the "Tare" button is held for > 15 sec?

  • capture a timestamp when the button is pressed
  • perform the Tare function if releases in < 15 sec
  • perform calibration is 15 sec expires
1 Like

You could still read the tare button after reset, and if it is pressed for longer than x seconds, call recalibrate.

1 Like

You could hijack the buttons.

Disconnect and yook the existing buttons to the Arduino. Then use transistors or CMOS switches driven by the Arduino in place of the buttons you now own.

So you can read the real buttons, and say anything you want to the device.

a7

1 Like

a common trick in these situations, is not to act when the button is ‘pressed’, but when it’s released.

You start the ‘timer’ when the button is pressed, then as time passes, you determine if it’s a short press, long press, or released… then do those appropriate actions.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.