using System; using System.Collections; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Presentation; using Microsoft.SPOT.Presentation.Controls; using Microsoft.SPOT.Presentation.Media; using Microsoft.SPOT.Presentation.Shapes; using Microsoft.SPOT.Touch; using Gadgeteer.Networking; using GT = Gadgeteer; using GTM = Gadgeteer.Modules; using GHI.OSHW.Hardware; // 追加、参照設定にも追加 using GHI.Hardware.FEZCerb; // 追加、参照設定にも追加 using Microsoft.SPOT.Hardware; using System.IO; namespace beeLEDblink { public partial class Program { GT.Timer tm = new GT.Timer(1000, GT.Timer.BehaviorType.RunContinuously); // This method is run when the mainboard is powered up or reset. void ProgramStarted() { tm.Start(); tm.Tick += new GT.Timer.TickEventHandler(TimeCounter); /* * Threadを用いないと次の警告が出る WARN: Total initialization time exceeds 10 seconds. : ProgramStarted is blocking execution, which means events and timers will not run properly. : Make sure not to use blocking code such as while(true) - use a GT.Timer instead. */ new Thread(proc).Start(); // proc(); } int timeCount=0; void TimeCounter(GT.Timer timer) { timeCount++; } void proc() { OutputPort LED1 = new OutputPort(Pin.PB1, false); while(true) { LED1.Write(true); Thread.Sleep(500); LED1.Write(false); Thread.Sleep(500); } /******************************************************************************************* Modules added in the Program.gadgeteer designer view are used by typing their name followed by a period, e.g. button. or camera. Many modules generate useful events. Type += to add a handler to an event, e.g.: button.ButtonPressed += If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.: GT.Timer timer = new GT.Timer(1000); // every second (1000ms) timer.Tick += timer.Start(); *******************************************************************************************/ // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging. } } }