ZEO-S 제품 자료입니다.
Timer 의 Interval 값을 조정하여 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_Flow { public partial class Form1 : Form { const int STEP = 25; int iStatus = 0; int NowStep = -STEP;
PIN_NAME pin1 = PIN_NAME.PA0 | PIN_NAME.PA2| PIN_NAME.PA4 | PIN_NAME.PA6 | PIN_NAME.PA8 | PIN_NAME.PA10 | PIN_NAME.PA16; PIN_NAME pin2 = PIN_NAME.PA1 | PIN_NAME.PA3 | PIN_NAME.PA5 | PIN_NAME.PA7 | PIN_NAME.PA9 | PIN_NAME.PA11; PIN_NAME pin3 = PIN_NAME.PB0 | PIN_NAME.PB2 | PIN_NAME.PB4 | PIN_NAME.PB6 | PIN_NAME.PB9 | PIN_NAME.PB11; PIN_NAME pin4 = PIN_NAME.PB1 | PIN_NAME.PB3 | PIN_NAME.PB5 | PIN_NAME.PB7 | PIN_NAME.PB8 | PIN_NAME.PB10;
ZeoLib ZEO = new ZeoLib(); public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { this.ZEO.Open(); this.ZEO.InitZeo(0); this.ZEO.PORT_DirOutputALL(); this.ZEO.Pin_Set(this.ZEO.PIN_ALL); }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { this.ZEO.Close(); }
private void timer1_Tick(object sender, EventArgs e) { if (timer1.Interval < 200) { timer1.Interval += NowStep/10; } else { timer1.Interval += NowStep; }
if (timer1.Interval < 100) { NowStep = STEP; } else if (timer1.Interval > 1000) { NowStep = -STEP; }
Console.WriteLine("int:"+timer1.Interval.ToString() +", nowstep:"+NowStep.ToString() );
switch (iStatus) { case 0: this.ZEO.Pin_Reset(pin1); this.ZEO.Pin_Set(pin4); break; case 1: this.ZEO.Pin_Reset(pin2); this.ZEO.Pin_Set(pin1);
break; case 2: this.ZEO.Pin_Reset(pin3); this.ZEO.Pin_Set(pin2); break; case 3: this.ZEO.Pin_Reset(pin4); this.ZEO.Pin_Set(pin3); break; default: break; }
iStatus = (++iStatus)%4; } } } |
전체 코드 Visual C# 2008 용
- [2015/06/08] ZEO-S C++ 라이브러리 ver. 1.01 (0)
- [2015/06/01] ZEO-S C++ 라이브러리 ver. 1.0 (0)
- [2015/04/15] 부저 실험 (7099)
- [2015/03/15] 블루투스로 스텝모터 제어 (4821)
- [2015/03/15] 시리얼 포트로 스텝모터 제어 (3319)
- [2014/11/28] 컴퓨터-아두이노 간의 블루투스 통신 (채팅) (4806)
- [2014/05/13] 0. 3개 이상의 Multi Task 작업 (3845)
- [2014/04/18] 0. LED 깜박이기 (3114)
- [2013/10/30] ZEO-S, CDS로 빛 밝기 -> LED ON/OFF ()
- [2013/10/28] ZEO-IO2 BOARD [ZEO IO 실험 보드2] (6465)