|
ŸÀÌ¸Ó µ¿ÀÛ |
||||||||||||
ÇнÀ¸ñÇ¥ |
|||||||||||||
ŸÀ̸Ӹ¦ µ¿ÀÛ ½ÃÅ°´Â ¹æ¹ý°ú È°¿ë ´É·ÂÀ» Å°¿î´Ù. |
|||||||||||||
ÇнÀÁÖÁ¦ |
|||||||||||||
ŸÀ̸Ӹ¦ µ¿ÀÛ½ÃÄÑ ÀÌ¿¡ µû¶ó LED°¡ µ¿ÀÛÇÏ°Ô ¸¸µç´Ù. |
|||||||||||||
¿¹½À³»¿ë |
|||||||||||||
´ÙÀ½ ÇÔ¼öÀÇ ³»¿ëÀ» ¾Ë¾Æ º»´Ù. |
|||||||||||||
½Ç½À¹æ¹ý |
|||||||||||||
¸ñ Â÷ |
|||||||||||||
[¿¹Á¦1 ÇÁ·Î±×·¥] 1. Project NameÀ» ÁÖ°í 1ÁÖ¿Í µ¿ÀÏÇÑ ¹æ¹ýÀ¸·Î ÇÁ·ÎÁ§Æ®¸¦ ¸¸µç´Ù. ¿©±â¼´Â ÇÁ·ÎÁ§Æ® À̸§À» Timer·Î ÇÑ´Ù. ÀÌÈÄ ³ª¸ÓÁö´Â ±âº»°ªÀ» ¼±ÅÃÇÑ´Ù.
|
|||||||||||||
2. ¾Æ·¡ ±×¸²°ú °°ÀÌ 4°³ÀÇ LED¸¦ ¸¸µé°í ½ºÀ§Ä¡¸¦ ¸¸µç´Ù.
|
°¢ ´ÜÃßÀÇ ¸¶¿ì½º ¿À¸¥ÂÊ Å°¸¦ ´©¸£°í Properties¸¦ È®ÀÎÇÏ¸é ´ÙÀ½°ú °°ÀÌ µÇ¾î ÀÖ´Ù. |
||||||||||||
Caption |
ID |
||||||||||||
LED1 |
IDC_CWBOOLEAN1 |
||||||||||||
LED2 |
IDC_CWBOOLEAN2 |
||||||||||||
LED3 |
IDC_CWBOOLEAN3 |
||||||||||||
LED4 |
IDC_CWBOOLEAN4 |
||||||||||||
½ºÀ§Ä¡ |
IDC_CWBOOLEAN5 |
||||||||||||
|
|||||||||||||
3. ´ÙÀ½ Å° ¸¦ ÀÌ¿ëÇÏ¿© ¾Æ·¡¿Í m_led1 ~ m_led4¿Í ½ºÀ§Ä¡¸¦ Á¤ÀÇ ÇÑ´Ù.
1. ½ºÀ§Ä¡¸¦ On, Off Çϸé LED°¡ µ¿ÀÛÇÏ°Ô ÇÑ´Ù. ½ºÀ§Ä¡ ¹öÆ°¿¡ ¸¶¿ì½º ¿À¸¥ÂÊÀ» µÎ¹ø Å©¸¯ÇÏ¿© OnValueChangedCwboolean5 ÇÔ¼ö¸¦ ¸¸µç´Ù.
½ºÀ§Ä¡ »óÅ°¡ º¯ÇÏ¸é ´ÙÀ½ ÇÔ¼ö°¡ ½ÇÇ౫°í OnµÇ¸é ŸÀ̸Ӹ¦ µ¿ÀÛ ½ÃÅ°°í OffµÇ¸é ŸÀ̸Ӹ¦ Á¤Áö ½ÃŲ´Ù. ŸÀÌ¸Ó ID´Â 1ÀÌ°í 300mSec ¸¶´Ù µ¿ÀÛÇÑ´Ù. |
|||||||||||||
|
void CTimerDlg::OnValueChangedCwboolean5(BOOL Value) { // TODO: Add your control notification handler code here if(m_switch.Value == 1) SetTimer(1,300,NULL);
else KillTimer(1); } |
|
|||||||||||
¸Þ´º View->ClassWizard¿¡¼ ¾Æ·¡±×¸²ÀÇ WM_TIMER¿¡ ¸¶¿ì½º¸¦ À§Ä¡ÇÏ°í ¿ÞÂÊ ¹öÆ°À» µÎ¹ø Å©¸¯ÇÏ¿© OnTimer ÇÔ¼ö¸¦ ¸¸µç´Ù.
È¸é ¿ÞÂÊÀÇ ClassView¿¡¼ CtimerDlg¿¡ ¸¶¿ì½º¸¦ À§Ä¡ÇÏ°í ¿À¸¥ÂÊ ¹öÆ°À» ´·¯ AddMember Vrable¡¦ |
|||||||||||||
|
|
||||||||||||
±×¸²°ú °°ÀÌiTimeÀ» ¼±¾ðÇÑ´Ù. ŸÀ̸Ӱ¡ µ¿ÀÛÇÒ ¶§¸¶´Ù. ITimeÀÌ 0°ú 1À» ¹Ýº¹ÇÏ¿© º¯ÇÏ°Ô ÇÏ¿© ÀÌ °ª¿¡ µû¶ó LED1ÀÌ On, Off µÇ°Ô ÇÑ´Ù.
|
|||||||||||||
|
BOOL CTimerDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here iTime = 0; return TRUE; // return TRUE unless you set the focus to a control } |
|
|||||||||||
|
void CTimerDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default iTime++; if(iTime
>= 2) iTime
= 0; m_led1.Value=0; m_led2.Value=0; if(iTime==0) m_led1.Value=1; else
if(iTime==1) m_led2.Value=1; CDialog::OnTimer(nIDEvent); } |
|
|||||||||||
AVR Åë½Å ÇÁ·Î±×·¥ |
|||||||||||||
[¿¹Á¦2 ÇÁ·Î±×·¥] C¾ð¾î ùÆäÀÌÁöÀÇ RS232 ±âº» ÇÁ·Î±×·¥À» ³»·Á¹Þ¾Æ À§ÀÇ ½ºÀ§Ä¡¿Í Led¸¦ Ãß°¡ÇÑ´Ù.
¡°OnTimer¡± ÇÔ¼ö¿¡ Åë½Å¿¡ ÇÊ¿äÇÑ ¹®ÀÚ¸¦ º¸³»´Â ÇÔ¼ö¸¦ Ãß°¡ ÇÑ´Ù. |
|||||||||||||
|
void CRs232Dlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default unsigned char buff[5]=""; iTime++; if(iTime >= 2) iTime = 0; m_led1.Value=0; m_led2.Value=0; if(iTime==0) { m_led1.Value=1; buff[0]=0x01; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else if(iTime==1) { m_led2.Value=1; buff[0]=0x02; m_ComuPort.WriteComm((unsigned
char*)buff,1); } CDialog::OnTimer(nIDEvent); } |
|
|||||||||||
|
|||||||||||||
°ú Á¦ |
|||||||||||||
1. ŸÀ̸Ӱ¡ On µÇ¸é LED 4°³°¡ Â÷·Ê´ë·Î On, Off µÇ°Ô ÇÁ·Î±×·¥À» ¸¸µå½Ã¿À. 2. ´ÙÀ½Àº 8*8 LED ÀÌ´Ù. ÀÌ ÇÁ·Î±×·¥À» ³»·Á ¹Þ°í ÀÚ±â À̸§À¸·Î °íÃÄ ¾²½Ã¿À. 3. ¾Æ·¡´Â [µ¿ÀÛ¸ðµå] ½ºÀ§Ä¡¸¦ Ãß°¡ÇÑ ±×¸²ÀÌ´Ù. [¸ðµå0]-µ¿ÀÛ Á¤Áö, [¸ðµå1]-4°³°¡ ÇÑ °³¾¿ Â÷·Ê·Î µ¿ÀÛ, [¸ðµå2]-4°³°¡ µ¿½Ã¿¡ Á¡µîÇϵµ·Ï ÇÁ·Î±×·¥ÇϽÿÀ. ¨ç ±×¸²°ú °°ÀÌ µ¿ÀÚ¸ðµå ³ëºê¸¦ Ãß°¡ÇÑ´Ù.
¨è ³ëºêÀÇ Values¸¦ ¡°Discrete¡±·Î ¹Ù²Û´Ù.
¨é View->ClassWizard ¿¡¼ ³ëºêÀÇ Member ¸¦ ¡°m_mode¡±·Î ¼±¾ðÇÑ´Ù.
¨ê ¡°OnTimer¡± ÇÔ¼ö¸¦ ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ÇÑ´Ù. |
|||||||||||||
|
void CTimerDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default iTime++; m_led1.Value=0; m_led2.Value=0; m_led3.Value=0; m_led4.Value=0;
if(m_mode.Value==1) { if(iTime >= 4) iTime = 0; if(iTime==0) m_led1.Value=1; else if(iTime==1) m_led2.Value=1; else if(iTime==2) m_led3.Value=1; else if(iTime==3) m_led4.Value=1; } else if(m_mode.Value==2) { if(iTime >= 2) iTime = 0; if(iTime==0) { m_led1.Value=0; m_led2.Value=0; m_led3.Value=0; m_led4.Value=0; } else { m_led1.Value=1; m_led2.Value=1; m_led3.Value=1; m_led4.Value=1; }
}
CDialog::OnTimer(nIDEvent); } |
|
|||||||||||
4. ŸÀ̸ÓÀÇ ½Ã°£À» ³ëºê·Î º¯È ½ÃŲ´Ù. ŸÀ̸Ӹ¦ À§ÇÑ ³ëºê¸¦ Ãß°¡ÇÏ°í [Scale]À» ¡°1000¡±À¸·Î [Value]¸¦ ¡°Discrete¡±·Î ÇÑ´Ù.
View->ClassWizard ¿¡¼ ŸÀ̸ÓÀÇ Member ¸¦ ¡°m_timer¡±·Î ¼±¾ðÇÑ´Ù.
ŸÀÌ¸Ó ³ëºê¸¦ ´õºíŬ¸¯ÇÏ¿© ¡°OnPointerValueChangedCwknob2¡± ÇÔ¼ö¸¦ ¾Æ·¡¿Í °°ÀÌ ÀÔ·ÂÇÏ¿© ³ëºêÀÇ °ªÀ» ŸÀ̸ÓÀÇ °ªÀ» º¯È ½ÃŲ´Ù. |
|||||||||||||
|
void CTimerDlg::OnPointerValueChangedCwknob2(long Pointer, VARIANT FAR* Value) { // TODO: Add your control notification handler code here SetTimer(1,(int)m_timer.Value,NULL); } |
|
|||||||||||
|
AVR Åë½Å ÇÁ·Î±×·¥ |
||||||||||||
À§ °úÁ¦4 ÇÁ·Î±×·¥À» AVR º¸µå¿Í ¿¬°áÇÏ¿© µ¿ÀÛ½ÃÄÑ º»´Ù. |
|||||||||||||
|
void CRs232Dlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default unsigned char buff[5]=""; iTime++; m_led1.Value=0; m_led2.Value=0; m_led3.Value=0; m_led4.Value=0;
if(m_mode.Value==1) { if(iTime >= 4) iTime = 0; if(iTime==0){ m_led1.Value=1; buff[0]=0x01; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else if(iTime==1){ m_led2.Value=1; buff[0]=0x02; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else if(iTime==2){ m_led3.Value=1; buff[0]=0x04; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else if(iTime==3){ m_led4.Value=1; buff[0]=0x08; m_ComuPort.WriteComm((unsigned char*)buff,1); } } else if(m_mode.Value==2) { if(iTime >= 2) iTime = 0; if(iTime==0) { m_led1.Value=0; m_led2.Value=0; m_led3.Value=0; m_led4.Value=0; buff[0]=0x00; m_ComuPort.WriteComm((unsigned
char*)buff,1); } else { m_led1.Value=1; m_led2.Value=1; m_led3.Value=1; m_led4.Value=1; buff[0]=0x0f; m_ComuPort.WriteComm((unsigned
char*)buff,1); }
} CDialog::OnTimer(nIDEvent); } void CRs232Dlg::OnPointerValueChangedCwknob2(long Pointer, VARIANT FAR* Value) { // TODO: Add your control notification handler code here SetTimer(1,(int)m_timer.Value,NULL); } |
|
|||||||||||