Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

1-button clock setting protocol?

Status
Not open for further replies.

Mr RB

Well-Known Member
Hi people, I need to use a single button for setting the time on a clock. Ideally it should not require any display features like making something flash etc.

It doesn't need to be super precise, so just setting seconds to zero when minutes are changed is ok, that allows the clock to be set within a couple of seconds without needing actual "seconds adjust" facility.

Here's what I got so far;

1; quick presses; inc minutes (when button is released), secs are reset
holding button down; inc hours, once per second, (nothing when released)

possible problem is that it can need up to 60 presses to set the minutes...

2. holding button; inc minutes, then inc faster after couple seconds
quick presses; inc hours

that might be a better way (faster to set minutes) but may not be as instinctive for the user.

Or maybe someone has their own method, or knows a "standard" commercial way of doing this?
 

Mr RB

Well-Known Member
Sorry for not waiting for replies, but I had a test of system 1 and it works pretty nice so it looks like that is the solution for now. :)

Code:
[B]Procedure;[/B]
* If button held down for 1 second; hours++, secs = 0
  * then if still held down; hours++ again (now every half second)
  * when long press is released; mins will not change
* any quick press (after release); mins++, secs = 0

Here is the MikroC code;

Code:
// Roman's easy "1-button" clock hours/mins setting system;

    // (this is done in a loop, about 12mS per loop)
    // CLOCK ADJUST button (lo = pressed)
    if(!PIN_BUT_ADJUST)
    {
      debounce++;
      
      // check for button HELD DOWN (adjust hours)
      if(debounce > 90)   // 90 is about 1.1 seconds
      {
        hours++;
        secs = 0;
        update_clock();     // format clock values
        display_clock();    // display to LCD
        debounce = 45;      // faster inc for next hour
      }
    }
    else   // else button is NOT pressed
    {
      // check for QUICK buttons press (adjust mins)
      if(debounce > 0 && debounce < 45)
      {
        mins++;
        secs = 0;
        update_clock();     // format clock values
        display_clock();    // display to LCD
      }
      debounce = 0;
    }

It works nice. It's instinctive and pretty fast, and since there is no minimum time for quick press (mins++) I can press it 60 times in about 20 seconds easily enough. Also if the final mins++ press is done when the minutes change on the reference clock it can sync the seconds to zero too, so it allows practical adjustment of hours/mins/secs.

I bet now it's all done and I put the project to bed someone will tell me they had a REALLY good way of doing it... ;)
 
Last edited:

Mr RB

Well-Known Member
Yes I am RB, and please don't say Jesus like that... Lot's of people will be offended by that. :)

This clock is 1x16 char LCD (only using 8 chars for now) and shows 12:00:00 (hh:mm:ss).
 

Gayan Soyza

Active Member
Now ok I'll give some my methods in few mins.

Entering to the time change mode
==========================

Pressing the button will goto time change mode.move the cursor to hours.Wait until release the button.

After release the button start a timer or a delay loop ex:5Seconds.
After 5 seconds expires move the cursor to minutes.

When the cursor is on hours section.
=============================

Pressing the button will change hours or press & hold will change hours speedily.
Releasing the button will start the timer on to move to minutes.

When the cursor is on minutes section.
=============================

Pressing the button will change minutes or press & hold will change minutes speedily.
Releasing the button will start the timer on & after expires exit from the time change mode.

In both cases the button release will turn on the timer & timer clears on every time change press.
 
Last edited:
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top