ÇнÀ¸ñÇ¥    1

ÇнÀÁÖÁ¦    1

¿¹½À³»¿ë    1

½Ç½À¹æ¹ý    1

°ú    Á¦    1

Áß¿äÇÔ¼ö    1

ŸÀÓ½ºÄÉÁì ¸¸µé±â

ÇнÀ¸ñÇ¥

ÇÏ·ç Áß ±â°è¸¦ µ¿ÀÛ ½ÃÅ°´Â ½Ã°£À» ÀÔ·ÂÇÏ°í ÀÌ¿¡ µû¶ó ±â°è¸¦ µ¿ÀÛ ½ÃŲ´Ù.

ÇнÀÁÖÁ¦

ÇÁ·Î±×·¥Àº ¡°½Ã°è ¸¸µé±â¡±ÀÇ ¡°°úÁ¦3¡± ÇÁ·Î±×·¥À» ÀÌ¿ëÇÏ°í ½Ã°£ÀÇ ÀԷ âÀ» ¡°NumEdit Control¡±¸¦ »ç¿ëÇÑ´Ù.

½Ã°£À» double ÇüÅÂÀÇ º¯¼ö¿¡ ÀúÀåÇÏ¿© ºñ±³ÇÑ´Ù.

¿¹½À³»¿ë

¡°NumEdit Control¡±ÀÇ ÇüŸ¦ ¡°Time¡±À¸·Î º¯°æÇϸé ÀÌ´Â ¡°double¡± ¶Ç´Â ¡°float¡±·Î ÀúÀåµÈ´Ù.

1½Ã°£ = 1/24    1ºÐ=1/(24*60)   1ÃÊ=1/(24*60*60) À¸·Î ÀúÀåµÈ´Ù.

À§¿Í °°ÀÌ °è»êÇÏ¿© ¡°½Ã°£+ºÐ+ÃÊ¡± ÀÔ·ÂÇÏ¸é µÈ´Ù.

½Ç½À¹æ¹ý

¸ñ    Â÷

(1)    ¡°½ÃÀ۽𣡱À» ¼±ÅÃÇÏ°í ¸¶¿ì½º ¿À¸¥ÂÊ Å°¸¦ ´­·¯¼­ ¾Æ·¡¿Í °°ÀÌ ¡°TimeÀ» ¼±ÅÃÇÑ´Ù. ¡°Á¾·á½Ã°£¡±°ú ¡°ÇöÀç½Ã°£¡±µµ °°Àº ¹æ¹ýÀ¸·Î ½Ã°£À¸·Î ¹Ù²Û´Ù.

(2)   ¸Þ´º¿¡¼­ ¡°View¡±ÀÇ  ¡°ClassWizard¡±¸¦ ¼±ÅÃÇÏ¿© À§ ¼¼ ½Ã°£ÀÇ Member VariableÀ» ¾Æ·¡¿Í °°ÀÌ ¡°m_StartTime¡±°ú ¡°m_EndTime¡± ¡°m_NowTime¡±À¸·Î ¼³Á¤ÇÑ´Ù.

(3)   OnTimer() ÇÔ¼ö¿¡ ÇöÀç ½Ã°£À» ¾ò°í À̸¦ ÀÌ ½Ã°£ÀÌ ½ÃÀÛ ½Ã°£º¸´Ù Å©°í Á¾·á ½Ã°£º¸´Ù ÀÛÀ¸¸é Led¸¦ On ½ÃÅ°°í ±×·¸Áö ¾ÊÀ¸¸é Off ½ÃŲ´Ù. ¾Æ·¡ÀÇ »¡°£»ö ±Û¾¾ÀÇ Ç¥½Ã¸¦ ÇÁ·Î±×·¥ÇÏ¸é µ¿ÀÛÀ» ½ÃÀÛÇÑ´Ù.

óÀ½

 

¿¹Á¦1  NumEdit ControlÀ» ÀÌ¿ëÇÑ ½Ã°£ÀÇ Ç¥½Ã¿Í µ¿ÀÛ

 

 

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);

 

      // ÀÌÀüÀÇ Led µ¿ÀÛÀº Á¤Áö ½ÃŲ´Ù.

      // ÃÊ=0 ÀÏ ¶§ led °¡ ÄÑÁø´Ù.

      //if(Tbuf[0]==0x30 && Tbuf[1]==0x30)

      //      m_led.Value=1;

      //else

      //      m_led.Value=0;

 

      // ÇöÀç ½Ã°£ °è»êÇÏ¿© Ç¥½ÃÇÑ´Ù.

      m_NowTime.Value =((double)(timeline[11]-0x30)*10+(double)(timeline[12]-0x30))/24.

              +((double)(timeline[14]-0x30)*10+(double)(timeline[15]-0x30))/(24.*60.)

              +((double)(timeline[17]-0x30)*10+(double)(timeline[18]-0x30))/(24.*60.*60.);

 

      // Led¸¦ µ¿ÀÛ ½ÃŲ´Ù.

      if(m_NowTime.Value>=m_StartTime.Value && m_NowTime.Value<=m_EndTime.Value)

              m_led.Value=1;

      else

              m_led.Value=0;

 

      UpdateData(FALSE);

 

      CDialog::OnTimer(nIDEvent);

}

 

´ÙÀ½Àº ¿Ï¼ºµÈ ÇÁ·Î±×·¥ÀÇ µ¿ÀÛÀ» ³ªÅ¸³½ °ÍÀÌ´Ù.

 

 

°ú    Á¦

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);

}

 

 À̹ø °úÁ¦ Àüü ¼Ò½º ÇÁ·Î±×·¥À» ¾Æ·¡¿¡¼­ ³»·Á ¹Þ¾Æ ½ÇÇàÇÏ¿© ºñ±³ÇØ º¸½Ã¿À.

[ÀüüÇÁ·Î±×·¥ ³»·Á¹Þ±â]