Timer 를 이용하여 LED 를 연속으로 이동하는 예제입니다.
동영상
코드 C#
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using ZeoDotNetLib;
namespace ZEO_Flow2 { public partial class Form1 : Form { // LED 상태 int iStatus = 0;
// ZEO-S 인스턴스 ZeoLib ZEO = new ZeoLib();
public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { // ZEO 초기화 this.ZEO.Open(); if (this.ZEO.IsOpened) { this.ZEO.InitZeo(0); this.ZEO.PORT_DirOutputALL(); this.ZEO.Pin_Set(this.ZEO.PIN_ALL); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { // ZEO 닫기 if (this.ZEO.IsOpened) this.ZEO.Close(); }
private void timer1_Tick(object sender, EventArgs e) { if (!this.ZEO.IsOpened) { Console.WriteLine("ZEO-S 가 연결되어 있지 않습니다."); return; }
switch (iStatus) { case 0: this.ZEO.Pin_Reset(PIN_NAME.PA0); break; case 1: this.ZEO.Pin_Reset(PIN_NAME.PA2); break; case 2: this.ZEO.Pin_Reset(PIN_NAME.PA4); break; case 3: this.ZEO.Pin_Reset(PIN_NAME.PA6); break;
case 4: this.ZEO.Pin_Set(PIN_NAME.PA0); break; case 5: this.ZEO.Pin_Reset(PIN_NAME.PA8); break; case 6: this.ZEO.Pin_Set(PIN_NAME.PA2); break; case 7: this.ZEO.Pin_Reset(PIN_NAME.PA10); break; case 8: this.ZEO.Pin_Set(PIN_NAME.PA4); break; case 9: this.ZEO.Pin_Reset(PIN_NAME.PA16); break; case 10: this.ZEO.Pin_Set(PIN_NAME.PA6); break; case 11: this.ZEO.Pin_Reset(PIN_NAME.PA1); break;
case 12: this.ZEO.Pin_Set(PIN_NAME.PA8); break; case 13: this.ZEO.Pin_Reset(PIN_NAME.PA3); break; case 14: this.ZEO.Pin_Set(PIN_NAME.PA10); break; case 15: this.ZEO.Pin_Reset(PIN_NAME.PA5); break; case 16: this.ZEO.Pin_Set(PIN_NAME.PA16); break; case 17: this.ZEO.Pin_Reset(PIN_NAME.PA7); break;
case 18: this.ZEO.Pin_Set(PIN_NAME.PA1); break; case 19: this.ZEO.Pin_Reset(PIN_NAME.PA9); break; case 20: this.ZEO.Pin_Set(PIN_NAME.PA3); break; case 21: this.ZEO.Pin_Reset(PIN_NAME.PA11); break; case 22: this.ZEO.Pin_Set(PIN_NAME.PA5); break; case 23: this.ZEO.Pin_Reset(PIN_NAME.PB0); break;
case 24: this.ZEO.Pin_Set(PIN_NAME.PA7); break; case 25: this.ZEO.Pin_Reset(PIN_NAME.PB2); break; case 26: this.ZEO.Pin_Set(PIN_NAME.PA9); break; case 27: this.ZEO.Pin_Reset(PIN_NAME.PB4); break; case 28: this.ZEO.Pin_Set(PIN_NAME.PA11); break; case 29: this.ZEO.Pin_Reset(PIN_NAME.PB6); break;
case 30: this.ZEO.Pin_Set(PIN_NAME.PB0); break; case 31: this.ZEO.Pin_Reset(PIN_NAME.PB9); break;
case 32: this.ZEO.Pin_Set(PIN_NAME.PB2); break; case 33: this.ZEO.Pin_Reset(PIN_NAME.PB11); break; case 34: this.ZEO.Pin_Set(PIN_NAME.PB4); break; case 35: this.ZEO.Pin_Reset(PIN_NAME.PB1); break; case 36: this.ZEO.Pin_Set(PIN_NAME.PB6); break; case 37: this.ZEO.Pin_Reset(PIN_NAME.PB3); break; case 38: this.ZEO.Pin_Set(PIN_NAME.PB9); break; case 39: this.ZEO.Pin_Reset(PIN_NAME.PB5); break; case 40: this.ZEO.Pin_Set(PIN_NAME.PB11); break; case 41: this.ZEO.Pin_Reset(PIN_NAME.PB7); break; case 42: this.ZEO.Pin_Set(PIN_NAME.PB1); break; case 43: this.ZEO.Pin_Reset(PIN_NAME.PB8); break; case 44: this.ZEO.Pin_Set(PIN_NAME.PB3); break; case 45: this.ZEO.Pin_Reset(PIN_NAME.PB10); break;
case 46: this.ZEO.Pin_Set(PIN_NAME.PB5); break; case 47: this.ZEO.Pin_Reset(PIN_NAME.PA0); break; case 48: this.ZEO.Pin_Set(PIN_NAME.PB7); break; case 49: this.ZEO.Pin_Reset(PIN_NAME.PA2); break; case 50: this.ZEO.Pin_Set(PIN_NAME.PB8); break; case 51: this.ZEO.Pin_Reset(PIN_NAME.PA4); break; case 52: this.ZEO.Pin_Set(PIN_NAME.PB10); break; default: iStatus = 2;
break; }
iStatus++;
} } } |
전체 코드 Visual C# 2008 용
출처: http://docs.whiteat.com/?p=396
'ZEO 시리즈' 카테고리의 다른 글
ZEO-S Pulse Counter, C# (0) | 2013.08.29 |
---|---|
ZEO-S, 스위치로 LED ON/OFF, C# (0) | 2013.06.13 |
ZEO-S, LED 이동 속도 조절, C# (0) | 2013.06.06 |
ZEO-S ADC 샘플링 테스트 C# (0) | 2013.04.16 |
ZEO-IO BOARD – ZEO IO 실험 보드 (0) | 2013.04.10 |