Split from: units digits less bright than tens digits

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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 !?!?

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

VIO47 wrote:
I have alredy explained why

and it made no sense!

 

seems it was so bad decision to not open another topic

Yes!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can close the topic or delete it, will try to find answers in other places. Thanks for kindness.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Split initiated

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.