# calendar using LED and C++

Page 1 of 1

## 3 Replies - 2264 Views - Last Post: 23 September 2009 - 12:06 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=127492&amp;s=00b54d0815c382f6590e58aae4840854&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 ydlem88

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

# calendar using LED and C++

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..

```#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)
}

{
//the main program
START:

clock();

goto START;
}

```

*mod edit: fixed code tags:

Is This A Good Question/Topic? 0

## Replies To: calendar using LED and C++

### #2 ydlem88

Reputation: 0
• 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..
we have problem in putting codes for leap year and changing the days..
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

{
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

{
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

### #3 NickDMax

Reputation: 2255
• 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?

### #4 wildgoose

• D.I.C Regular

Reputation: 67
• 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