{"id":317,"date":"2012-07-26T13:49:13","date_gmt":"2012-07-26T13:49:13","guid":{"rendered":"http:\/\/foxware.co.uk\/?p=317"},"modified":"2012-07-26T13:49:13","modified_gmt":"2012-07-26T13:49:13","slug":"interrupt-port-handling","status":"publish","type":"post","link":"http:\/\/foxware.co.uk\/?p=317","title":{"rendered":"Interrupt Port Handling"},"content":{"rendered":"<pre class=\"lang:c# decode:true\" >\r\n\r\n\r\n\/\/ this moved out here so it can be used by other methods\r\nstatic OutputPort LED;\r\n\r\npublic static void Main()\r\n{\r\n\tLED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true);\r\n\t\/\/ the pin will generate interrupt on high and low edges\r\n\tInterruptPort IntButton =\r\n\t\tnew InterruptPort((Cpu.Pin)FEZ_Pin.Interrupt.LDR, true,\r\n\tPort.ResistorMode.PullUp,\r\n\tPort.InterruptMode.InterruptEdgeBoth);\r\n\t\/\/ add an interrupt handler to the pin\r\n\tIntButton.OnInterrupt += new NativeEventHandler(IntButton_OnInterrupt);\r\n\t\/\/do anything you like here\r\n\tThread.Sleep(Timeout.Infinite);\r\n}\r\n\r\nstatic void IntButton_OnInterrupt(uint port, uint state,\r\n\t\tDateTime time)\r\n{\r\n\t\/\/ set LED to the switch state\r\n\tLED.Write(state == 0);\r\n}\r\n\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\/\/ this moved out here so it can be used by other methods static OutputPort LED; public static void Main() { LED = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, true); \/\/ the pin will generate interrupt on high and low edges InterruptPort IntButton = &hellip; <a href=\"http:\/\/foxware.co.uk\/?p=317\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[],"_links":{"self":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/317"}],"collection":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317"}],"version-history":[{"count":1,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions"}],"predecessor-version":[{"id":318,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/317\/revisions\/318"}],"wp:attachment":[{"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/foxware.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}