## Split from: units digits less bright than tens digits

10 posts / 0 new
Author
Message

Hi, I will post here another issue I have even it is not related to this topic, just to not open another one. I am working on a clock with calendar, managed to make a working calendar with my limited knowledges and some examples from different sites. I took an example for adjusting the time and extended for adjusting the calendar but I need 7 pins to adjust each value of the time and calendar. Please give me a hint how I can use only 3 pins, for example, with one to select the value I want to adjust and with the other 2 to adjust up or down. Thank you.

```while (1)
{
if(!(SET_PIN & (1<<SET_HOUR))){
hour++;
if(hour > 23)
hour = 0;}
if(!(SET_PIN & (1<<SET_MINUTE))){
minute++;
if(minute > 59)
minute = 0;}
if(!(SET_PIN & (1<<SET_SECONDS))){
second = 0;}
if(!(SET_PIN & (1<<SET_DAY))){
if (year%4 == 0){
Days[1] = 29;}
if (day > Days[month]){
day = 1;}
day++;}
if(!(SET_PIN & (1<<SET_WEEKDAY))){
if (weekday > 7){
weekday = 0;}
weekday++;}
if(!(SET_PIN & (1<<SET_MONTH))){
if (month > 11){
month = 0;}
month++;}
if(!(SET_PIN & (1<<SET_YEAR))){
if (year > 99){
year = 0;}
year++;}

_delay_ms(1000);
}```

Last Edited: Fri. Sep 15, 2017 - 06:38 PM

Don't worry, you don't pay tax on opening new topics. I'm sure a moderator will soon split this new question to a new topic.

regarding you question, I suppose you can just copy how this is done in a clock, that is, a button selects the active field, that is indicated to the user by blinking, while the other buttons increase/decrease the value.

I agree with El Tangas.   Look at how your digital watch adjusts time.    Often with just a "mode button" and an "increment button".

You do it with a "state machine" from the mode button.   You don't need to adjust time on your watch very often.   So you put up with the inconvenience.

Some devices manage with a single button.   e.g. hold for 10 secs to change mode. short press to increment.

Yes,  a Moderator will probably split this thread.

David.

Hi, I missed to mention, I am no more working with 7 digits LED display, that attempt was only to learn some things, currently I use a graphic LCD, so I asume it should be done in a diferent way. Thank you for replies.

VIO47 wrote:

Hi, I missed to mention, I am no more working with 7 digits LED display, that attempt was only to learn some things, currently I use a graphic LCD, so I asume it should be done in a diferent way. Thank you for replies.

No, no different way is required.

A well designed program will separate out all the various elements so that they do not rely on each other. So in your clock case, the display routine, the button routine and the time-keeping routine will all do their thing without needing to know anything about the others.

'This forum helps those who help themselves.'

pragmatic  adjective dealing with things sensibly and realistically in a way that is based on practical rather than theoretical consideration.

VIO47 wrote:
I am no more working with 7 digits (sic) LED display

So why on earth are you posting in a thread about 7-segment LEDs !?!?

I have alredy explained why, seems it was so bad decision to not open another topic, sorry.

VIO47 wrote:
I have alredy explained why

seems it was so bad decision to not open another topic

Yes!