标签:style blog class code java ext javascript width color int string
OutputPort led = new OutputPort(Pins.ONBOARD_LED, false); while(true) { led.Write(true); Thread.Sleep(250); led.Write(false); Thread.Sleep(250); }
它看起来像这样 :D
InterruptPort button = new InterruptPort(Pins.ONBOARD_SW1, true, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh); button.OnInterrupt += new NativeEventHandler(button_OnInterrupt); InterruptPort button1 = new InterruptPort(Pins.GPIO_PIN_D3, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow); button1.OnInterrupt += new NativeEventHandler(button_OnInterrupt); //在对应边沿触发,使用了软件防抖 static void button_OnInterrupt(uint data1, uint data2, DateTime time) { if (lasttime.AddMilliseconds(400) < time) { Debug.Print(data1.ToString() + "," + data2.ToString() + "," + time.ToString()); lasttime = time; ledflag = !ledflag; led.Write(ledflag); } }
后面测试了多线程,实现也比较简单,C#写代码十分舒服~
标签:style blog class code java ext javascript width color int string
原文地址:http://www.cnblogs.com/yitiandelan/p/My_Netduino_2.html