calendar using LED and C++

Microcontroller calendar in C++

Page 1 of 1

3 Replies - 1793 Views - Last Post: 23 September 2009 - 12:06 PM Rate Topic: -----

#1 ydlem88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-September 09

calendar using LED and C++

Post icon  Posted 23 September 2009 - 12:31 AM

please help how to troubleshoot this code.. we want to turn on the LED to a desired date to indicate the day, month and the date..
please help us


#include <easyC.h>

_GPIO

	int millisec = 0;
	int sec = 0;
	int min = 0;
	int hour = 0;
	int day = 0;
	int week = 0;

sub_clock()
{
	if(millisec == 0) //wait until 1000 milliseconds
		
		{
			sec++; //increase the seconds with 1
			millisec = 1000; //put again the milliseconds on 1000
		}

	//To determine the values of hour,min and second
	
	if(sec>59)	//if the 59 sec are over
		{
			sec = 0; //put the value of second on zero again
			min++;   //And increase the min with 1
		}

	if(min>59)	   //if the 59 min are over
		{
			min = 0; //put the value of min on zero again
			hour++;  //increase the hour with 1
		}

	if(hour>23)	  //if the 24 hour are over
		{
			hour = 0;//put the value of hour on zero again
			day++;   //increase the day with 1
		}
}
		
sub_calendar1()
{
	for (day>30)

	for (day>27)

	for (day>29)
}
		
task main()
	{
		//the main program
	START:

	clock();
	
	goto START;
	}




*mod edit: fixed code tags: :code:

Is This A Good Question/Topic? 0
  • +

Replies To: calendar using LED and C++

#2 ydlem88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-September 09

Re: calendar using LED and C++

Posted 23 September 2009 - 12:47 AM

we have project in our microcontroller class and we want to use this device to make a calendar..
please help us in troubleshooting our code..
we have problem in putting codes for leap year and changing the days..
please feel free to comment
we hope you can answer our problem before september 28.. thank you so much..
this consists of two different code for one purpose.. TO MAKE CALENDAR USING MICROCONTROLLER AND C++ LANGUAGE


#include<easyC.h>
_GPIO

task main()
{
	int millisec = 1000;
	int sec = 0;
	int min = 0;
	int hour = 0;
	{
	//the main program
	if(millisec == 0) //wait until 1000 milliseconds
		{
			sec++; //increase the seconds with 1
			millisec = 1000; //put again the milliseconds on 1000
		}

	//To determine the values of hour,min and second
	if(sec>59) //if the 59 sec are over
		{
			sec = 0; //put the value of second on zero again
			min++; //And increase the min with 1
		}

	if(min>59) //if the 59 min are over
		{
			min = 0; //put the value of min on zero again
			hour++; //increase the hour with 1
		}

	if(hour>23) //if the 24 hour are over
		{
	hour = 0; //put the value of hour on zero again
		}
	}
}



-------------------------------------------------------------------
#include<easyC.h>
_GPIO

task main()
{
	int millisec = 0;
	int sec = 0;
	int min = 0;
	int hour = 0;
	int day = 0;
	int week = 0;
	int month = 0;

	{
	//the main program
	if(millisec == 0) //wait until 1000 milliseconds
		{
			sec++; //increase the seconds with 1
			millisec = 1000; //put again the milliseconds on 1000
			START:
				LOW(0);
				LOW(1);
				LOW(2);
				HIGH(0);
				PAUSE(millisec / 2);
				HIGH(1);
				PAUSE(millisec / 2);
			goto START;

		}
	//To determine the values of hour,min and second
	if(sec>59) //if the 59 sec are over
		{
		
		sec = 0; //put the value of second on zero again
		min++; //And increase the min with 1

		}

	if(min>59) //if the 59 min are over
		{
			min = 0; //put the value of min on zero again
			hour++; //increase the hour with 1
		}

	if(hour>23) //if the 24 hour are over
		{
			hour = 0; //put the value of hour on zero again
			day++; //increase the day with 1
		}

	if(day>6) //if the 7 days are over
		{
			day = 0; //put the value of day on zero again
			week++; //increase the day with 1
		}

	if(week>3) //if the 3 weeks are over
		{
			week = 0; //put the value of day on zero again
			month++; //increase the month with 1
		}

	}


This post has been edited by ydlem88: 23 September 2009 - 12:49 AM

Was This Post Helpful? 0
  • +
  • -

#3 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: calendar using LED and C++

Posted 23 September 2009 - 06:28 AM

I am not an expert embedded developer but I would imagine that they would need to know a little more about what you are working with than this:

What microcontroller are you using. There are TONS of different microcontrollers from a fistful of different vendors and each one tends to have its own quirky little compiler. Do you know what vendor this is/what compiler/IDE this is using?
Was This Post Helpful? 0
  • +
  • -

#4 wildgoose  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 67
  • View blog
  • Posts: 468
  • Joined: 29-June 09

Re: calendar using LED and C++

Posted 23 September 2009 - 12:06 PM

1st of all you're using C, not C++. Embedded systems are mostly C and assembly based!


So are you using an Alpha-Numeric display?
Or three clusters of discrete LED's.
12 one for each month.
31 one for each day of the month
N { 2009, 2010, ...., N }

OR more, since your second code post now has time!

Don't need the physical hardware details if descrete LED's.
Just void LedMonth( char nMonth )
void LedDay( char nDay )
void LedYear( char nYear )

If using alpha-numric, then could do it this same way or differently!

Though knowing the hardware details is always good to know!

This post has been edited by wildgoose: 23 September 2009 - 12:09 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1