½Ã°è ¸¸µé±â |
|||||||||||||||||||||||||||||||||||||||
ÇнÀ¸ñÇ¥ |
|||||||||||||||||||||||||||||||||||||||
ŸÀ̸ÓÀÇ µ¿ÀÛÀ» ¾Ë¾Æº¸°í ±× È°¿ëÀ» ¾Ë¾Æ º»´Ù. |
|||||||||||||||||||||||||||||||||||||||
ÇнÀÁÖÁ¦ |
|||||||||||||||||||||||||||||||||||||||
ŸÀ̸Ӹ¦ 0.3ÃÊ °£°ÝÀ¸·Î µ¿ÀÛ½ÃÄÑ À̸¦ ÅؽºÆ®·Î Ãâ·Â½ÃŲ´Ù. ÁÖ±âÀûÀ¸·Î µ¿ÀÛÇØ¾ß ÇÏ´Â °÷¿¡ ŸÀ̸Ӹ¦ È°¿ëÇÑ´Ù. |
|
||||||||||||||||||||||||||||||||||||||
¿¹½À³»¿ë |
|||||||||||||||||||||||||||||||||||||||
´ÙÀ½ ÇÔ¼ö¸¦ ¾Ë¾Æ º»´Ù. |
|||||||||||||||||||||||||||||||||||||||
½Ç½À¹æ¹ý |
|||||||||||||||||||||||||||||||||||||||
¸ñ Â÷ |
|||||||||||||||||||||||||||||||||||||||
(1) ÇÁ·ÎÁ§Æ® À̸§À» ClockÀ¸·Î ¸¸µç´Ù. ¾Æ·¡ ÇØ´ç¹øÈ£ÀÇ ÇÁ·Î±×·¥Àº ClockDlg.cpp¿¡ »¡°£ ±Û¾¾·Î Ç¥½ÃµÇ¾î ÀÖ´Ù. (2) ¸Þ´ºÀÇ View->ClassWizard¿¡¼ 0.5Ãʸ¶´Ù µ¿ÀÛÇϴ ŸÀ̸Ӹ¦ ¼³Á¤ÇÑ´Ù. WM_TIMER ¸¦ ¸¶¿ì½º ¿ÞÂÊ ¹öÆ°À» µÎ¹ø Å©¸¯Çϸé OnTimer ÇÔ¼ö°¡ ¸¸µç´Ù.
BOOL CClockDlg::OnInitDialog()¿¡ SetTimer(1,500,NULL);¸¦ Ãß°¡ÇÏ¿© ŸÀ̸Ӱ¡ 0.5Ãʸ¶´Ù µ¿ÀÛÇÏ°Ô ÇÑ´Ù. (3) Edit Box¸¦ ¸¸µç´Ù.
(5) Edit BoxÀÇ VariableÀ» ¾Æ·¡¿Í °°ÀÌ Ãß°¡ÇÑ´Ù.
(6) #include <sys/timeb.h> ½Ã°£À» ¾ò±âÀ§ÇØ Çì´õÆÄÀÏÀ» Ãß°¡ÇÑ´Ù. (7) OnTimer() ÇÔ¼ö¿¡ ½Ã°£À» ¾ò°í Edit Box¿¡ Ãâ·ÂÇϱâ À§ÇÑ ÇÁ·Î±×·¥À» Ãß°¡ÇÑ´Ù. OnTimer() ÇÔ¼öÀÇ timeline ¿¡´Â "Fri Nov 09 |
|||||||||||||||||||||||||||||||||||||||
°ú Á¦ |
|||||||||||||||||||||||||||||||||||||||
1. ´ÙÀ½Àº ¡°²ÞÀǼҸ®.wav¡± »ç¿îµå¸¦ ¿¬ÁÖÇÏ´Â ÇÔ¼öÀÌ´Ù. ´ÙÀ½À» ÀÌ¿ëÇÏ¿© ÇÏ·çÁß ÀÏÁ¤ÇÑ ½Ã°£ÀÌ µÇ¸é À½¾ÇÀ» ¿¬ÁÖÇÏ´Â ÇÁ·Î±×·¥À» ¿Ï¼ºÇϽÿÀ. ¿øÇÏ´Â À½¾ÇÀ» ¿¬ÁÖÇÏ·Á¸é ¡°²ÞÀǼҸ®.wav¡± ´ë½Å ´Ù¸¥ À½¾ÇÆÄÀÏÀ» ³ÖÀ¸¸é µÈ´Ù. sndPlaySound("²ÞÀǼҸ®", SND_SYNC); |
|||||||||||||||||||||||||||||||||||||||
2. ¾Æ·¡ ±×¸²°ú °°ÀÌ ¿¡µðÆ® âÀ» Çϳª ´õ ¸¸µé¾î¼ ¿©±â¿¡´Â ½Ã,ºÎ,ÃÊ Áß¿¡ Ãʸ¸ Ç¥½Ã µÇµµ·Ï ÇÁ·Î±×·¥ ÇÑ´Ù.
º¯¼ö´Â ¾Æ·¡¿Í °°ÀÌ Á¤ÀÇ ÇÑ´Ù.
ŸÀÌ¸Ó ÇÔ¼ö¸¦ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ÇÑ´Ù. |
|||||||||||||||||||||||||||||||||||||||
|
void CClockDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default struct _timeb timebuffer; // (7) char *timeline; char Tbuf[9]; _ftime( &timebuffer ); timeline = ctime( & ( timebuffer.time ) ); Tbuf[0]=timeline[11]; Tbuf[1]=timeline[12]; Tbuf[2]=timeline[13]; Tbuf[3]=timeline[14]; Tbuf[4]=timeline[15]; Tbuf[5]=timeline[16]; Tbuf[6]=timeline[17]; Tbuf[7]=timeline[18]; Tbuf[8]=0x00; m_clock.Format("%s",Tbuf); // ÃÊ
¸¸À» Ç¥½ÃÇϴ â Tbuf[0]=timeline[17]; Tbuf[1]=timeline[18]; Tbuf[2]=0x00; m_clock1.Format("%s",Tbuf); UpdateData(FALSE); CDialog::OnTimer(nIDEvent); } |
|
|||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||
3. ±×¸²°ú °°ÀÌ Led¸¦ Ãß°¡ÇÏ¿© 0ÃÊ°¡ µÉ ¶§ OnÀÌ µÇµµ·Ï ÇÁ·Î±×·¥ ÇÏ¿©¶ó.
4. ¾Æ·¡´Â Led¸¦ 4°³ ¸¸µé¾î ÃÊħÀÇ ½Ê´ÜÀ§ ¼ýÀÚ¿¡ µû¶ó led°¡ ÄÑÁöµµ·Ï ÇÁ·Î±×·¥ÇÑ°ÍÀÌ´Ù.
À§ ÇÁ·Î±×·¥À¸ VariableÀº ¾Æ·¡¿Í °°ÀÌ Á¤ÀÇ ÇÑ´Ù.
|
|||||||||||||||||||||||||||||||||||||||
AVR Åë½Å ÇÁ·Î±×·¥ |
|||||||||||||||||||||||||||||||||||||||
À§ ¿¹Á¦4 ¸¦ AVR º¸µå¿Í ¿¬°áÇÏ¿© µ¿ÀÛ ½ÃŲ´Ù. C¾ð¾î ùÆäÀÌÁöÀÇ RS232 ±âº» ÇÁ·Î±×·¥À» ³»·Á¹Þ¾Æ À§ÀÇ Led¸¦ Ãß°¡ÇÑ´Ù. [PCÅë½ÅÇÁ·Î±×·¥ ³»·Á¹Þ±â]
Variable Àº ¾Æ·¡¿Í °°ÀÌ Á¤ÀÇ ÇÑ´Ù.
OnTimer ÇÔ¼ö¸¦ ¾Æ·¡¿Í °°ÀÌ Á¤ÀÇ ÀÛ¼ºÇÑ´Ù. |
|||||||||||||||||||||||||||||||||||||||
|
void CRs232Dlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default struct _timeb timebuffer; // (7) char *timeline; char Tbuf[9]; unsigned char buff[5]=""; _ftime( &timebuffer ); timeline = ctime( & ( timebuffer.time ) ); Tbuf[0]=timeline[11]; Tbuf[1]=timeline[12]; Tbuf[2]=timeline[13]; Tbuf[3]=timeline[14]; Tbuf[4]=timeline[15]; Tbuf[5]=timeline[16]; Tbuf[6]=timeline[17]; Tbuf[7]=timeline[18]; Tbuf[8]=0x00; m_clock.Format("%s",Tbuf); // ÃÊ ¸¸À» Ç¥½ÃÇϴ â Tbuf[0]=timeline[17]; Tbuf[1]=timeline[18]; Tbuf[2]=0x00; m_clock1.Format("%s",Tbuf); // ÃÊħÀÇ ½Ê´ÜÀ§ ¼ýÀÚ¿¡ µû¶ó led °¡ ÄÑÁø´Ù. if(Tbuf[0]==0x30) { m_led0.Value=1; m_led1.Value=0; m_led2.Value=0; m_led3.Value=0; buff[0]=0x01; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else if(Tbuf[0]==0x31) { m_led0.Value=0; m_led1.Value=1; m_led2.Value=0; m_led3.Value=0; buff[0]=0x02; m_ComuPort.WriteComm((unsigned char*)buff,1); } else if(Tbuf[0]==0x32) { m_led0.Value=0; m_led1.Value=0; m_led2.Value=1; m_led3.Value=0; buff[0]=0x04; m_ComuPort.WriteComm((unsigned char*)buff,1); } else if(Tbuf[0]==0x33) { m_led0.Value=0; m_led1.Value=0; m_led2.Value=0; m_led3.Value=1; buff[0]=0x08; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else { m_led0.Value=0; m_led1.Value=0; m_led2.Value=0; m_led3.Value=0; buff[0]=0x00; m_ComuPort.WriteComm((unsigned
char*)buff,1); } UpdateData(FALSE); CDialog::OnTimer(nIDEvent); } |
|
|||||||||||||||||||||||||||||||||||||
À̹ø °úÁ¦ Àüü ¼Ò½º ÇÁ·Î±×·¥À» ¾Æ·¡¿¡¼ ³»·Á ¹Þ¾Æ ½ÇÇàÇÏ¿© ºñ±³ÇØ º¸½Ã¿À. |
|||||||||||||||||||||||||||||||||||||||
Áß¿äÇÔ¼ö |
|||||||||||||||||||||||||||||||||||||||
_ftime
Gets the
current time. void _ftime( struct
_timeb *timeptr );
For
additional compatibility information, see Compatibility
in the Introduction. Libraries
Return
Value _ftime does not return a
value, but fills in the fields of the structure pointed to by timeptr. Parameter timeptr Pointer
to _timeb structure Remarks The _ftime
function gets the current local time and stores it in the structure pointed
to by timeptr. The _timeb structure is defined in SYS\TIMEB.H.
It contains four fields: dstflag Nonzero
if daylight savings time is currently in effect for the local time zone. (See
_tzset for an explanation of how
daylight savings time is determined.) millitm Fraction
of a second in milliseconds. time Time
in seconds since midnight ( timezone Difference
in minutes, moving westward, between UTC and local time. The value of timezone
is set from the value of the global variable _timezone (see _tzset). Example
Output
See Also asctime, ctime, gmtime,
localtime, time ctime, _wctime
Convert a time value
to a string and adjust for local time zone settings. char *ctime( const
time_t *timer ); wchar_t *_wctime( const
time_t *timer );
For additional
compatibility information, see Compatibility
in the Introduction. Libraries
Return Value Each of these
functions returns a pointer to the character string result. If time
represents a date before midnight, January 1, 1970, UTC, the function returns
NULL. Parameter timer Pointer to stored
time Remarks The ctime
function converts a time value stored as a time_t
structure into a character string. The timer value is usually obtained
from a call to time, which returns the number of seconds elapsed since
midnight (
A 24-hour clock is
used. All fields have a constant width. The newline character ('\n') and the
null character ('\0') occupy the last two positions of the string. The converted
character string is also adjusted according to the local time zone settings.
See the time, _ftime,
and localtime functions for information
on configuring the local time and the _tzset
function for details about defining the time zone environment and global
variables. A call to ctime
modifies the single statically allocated buffer used by the gmtime and
localtime functions. Each call to one of these routines destroys the
result of the previous call. ctime shares a static buffer with the asctime
function. Thus, a call to ctime destroys the results of any previous
call to asctime, localtime, or gmtime. _wctime is a wide-character
version of ctime; _wctime returns a pointer to a wide-character
string. _wctime and ctime behave identically otherwise. Generic-Text Routine
Mappings
Example
Output
See Also asctime, _ftime, gmtime, localtime, time |
|||||||||||||||||||||||||||||||||||||||