门Ajar / Raspberry / GPIO / Python / C# [英] Door Ajar/Raspberry/GPIO/Python/C#

查看:57
本文介绍了门Ajar / Raspberry / GPIO / Python / C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是IoT的新手,对于我的第一个项目,我正在努力完成我在
找到的样本 https://www.richlynch.com/category/pi-garage-alert/。我完全使用了作者使用的Raspbian操作系统。但是,我真的很想尝试使用Windows 10 IoT Core。 
我在"Hello World"中取得了成功。在使用W10的设备上,但我似乎无法让GPIO正常工作。  (我承认我是一个NOOB,即使这个声明可能不正确 - 这就是我从源代码和其他
阅读中得出的结论。) 我不确定这是因为我不知道如何翻译作者所包含的Python示例,或者是否需要在C#中完成不同的操作。 在我看来,我需要理解并翻译以下命令,但是我可以获得的

I'm a newbie to IoT, and for my first project I'm struggling through a sample I found at https://www.richlynch.com/category/pi-garage-alert/.I have it all working well with the Raspbian OS that the author used. However, I'd really like to try this using Windows 10 IoT Core.  I've had success with "Hello World" on the device using W10, but I can't seem to get the GPIO working.  (I admit that I'm such a NOOB, even that statement may be incorrect - that's just what I've concluded from the source code and other reading.)  I'm not sure if this is because I don't know how to translate the Python sample the author included, or if it needs to be done very differently in C#.  It looks to me like I need to understand and translate the following commands, but that's about as far as I'm able to get:


  • GPIO.setmode()
  • GPIO.setup()
  • GPIO.input()
  • GPIO.cleanup()

我尝试使用以下内容,但未成功:

I've tried using the following, but have been unsuccessful:

var gpio = GpioController.GetDefault();
var pin = gpio.OpenPin(pinNumber);
pin.ValueChanged += Pin_ValueChanged;

所有出现都可以使用,但是"Pin_ValueChanged"永远不会被召唤。 如果我使用"pin.Read()"检查引脚的状态,它永远不会改变。 我无法让传感器产生任何有意义的变化。

Everything appears to work, but "Pin_ValueChanged" never gets called.  If I check the status of the pin using "pin.Read()", it never changes.  I can't get the sensor to produce any meaningful change.

想法? 任何帮助将不胜感激!

Ideas?  Any help would be much appreciated!

谢谢!

布拉德。

推荐答案

亲爱的朋友,

如果您使用GPIO作为输出,我建议您在MSDN上参考此示例:

If you use GPIO as Output, I suggest you refer to this sample on MSDN:

https://developer.microsoft.com/en- us / windows / iot / samples / helloblinky

如果您使用GPIO作为输入,我建议您在MSDN上参考此示例:

If you use GPIO as Input, I suggest you refer to this sample on MSDN:

https://developer.microsoft.com / en-us / windows / iot / samples / pushbutton

您可以在"Pin_ValueChanged"中设置断点。事件。如果代码无法进入按下按钮时设置的断点,只需确保按钮引脚的Init功能正常。

You can set a breakpoint in "Pin_ValueChanged" event. If the Code can't get to the breakpoint you set when you push the button, just to make sure the Init function of Button Pin is OK.


这篇关于门Ajar / Raspberry / GPIO / Python / C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆