您现在的位置是:首页 > 文章详情

张高兴的 Windows 10 IoT 开发笔记:串口红外编解码模块 YS-IRTM

日期:2018-05-24点击:456

This is a Windows 10 IoT Core project on the Raspberry Pi 2/3, coded by C#.

GitHub: https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/IRTM

Image

YS_IRTM

Reference

https://github.com/ZhangGaoxing/windows-iot-demo/tree/master/IRTM/Reference

Connect

  • RXD - UART0 TX (PIN 8)
  • TXD - UART0 RX (PIN 10)
  • VCC - 5V
  • GND - GND

Note

There is one Serial UART available on the RPi2/3: UART0

  • Pin 8 - UART0 TX
  • Pin 10 - UART0 RX

You need add the following capability to the Package.appxmanifest file to use Serial UART.

<Capabilities> <DeviceCapability Name="serialcommunication"> <Device Id="any"> <Function Type="name:serialPort" /> </Device> </DeviceCapability> </Capabilities>

What Contains

In IRTM.cs file

/// <summary> /// Initialize YS-IRTM /// </summary> public async Task InitializeAsync(); /// <summary> /// Send Order /// </summary> /// <param name="code">Order</param> public async Task SendAsync(byte[] code); /// <summary> /// Read Order /// </summary> public async Task<byte[]> ReadAsync(); /// <summary> /// Set YS-IRTM Address /// </summary> /// <param name="address">Address from 1 to FF</param> public async Task SetAddressAsync(byte address); /// <summary> /// Set YS-IRTM Baud Rate /// </summary> /// <param name="rate">Baud Rate</param> public async Task SetBaudRateAsync(IrtmBaudRate rate); /// <summary> /// Return YS-IRTM /// </summary> /// <returns>YS-IRTM</returns> public SerialDevice GetDevice(); /// <summary> /// Cleanup /// </summary> public void Dispose();

How to Use

  • First, you need to create a IRTM object. After that you should call InitializeAsync() to initialize.
IRTM irtm = new IRTM(); await irtm.InitializeAsync();
  • Second, SendAsync().
irtm.SendAsync(new byte[] { 0x01, 0x02, 0x03 });
  • If you want to close the sensor, call Dispose().
irtm.Dispose();
原文链接:https://yq.aliyun.com/articles/596909
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章