![]() | ![]() | ![]() |
| |||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
![]() |
| | Tools |
| | #1 |
|
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? | |
| |
| | #2 |
|
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: Procedure; * 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 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;
}
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 by Mr RB; 2nd November 2009 at 10:19 AM. | |
| |
| | #3 |
|
Are you roman black? Is your clock showing seconds?Whats the display SSD's?LCD'S Matrix? Sorry I saw in your code it was a LCD. Last edited by Gayan Soyza; 2nd November 2009 at 02:01 PM. | |
| |
| | #4 |
|
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). | |
| |
| | #5 |
|
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 by Gayan Soyza; 2nd November 2009 at 02:37 PM. | |
| |
|
| Tags |
| 1button, clock, protocol, setting |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| Using one button count up/one button to count down using 4510 | pageygeeza | Electronic Projects Design/Ideas/Reviews | 15 | 11th February 2009 03:35 PM |
| How would you convert a push button to a remote button? | stodouble | General Electronics Chat | 1 | 22nd September 2008 04:37 AM |
| odd project, 1 button adds a light 1 button takes a light away with sound. | KevinAlaska | Electronic Projects Design/Ideas/Reviews | 15 | 6th June 2007 05:38 AM |
| digital clock setting the time mode | Jay Duluguin | Electronic Projects Design/Ideas/Reviews | 0 | 19th February 2004 11:09 PM |
| Digital clock setting mechanism | patroclus | Electronic Projects Design/Ideas/Reviews | 6 | 17th November 2003 01:38 PM |