张高兴的 Windows 10 IoT 开发笔记:串口红外编解码模块 YS-IRTM
2020-01-15 09:32
976 查看
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
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://www.cnblogs.com/zhanggaoxing/p/9090979.html
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 张高兴的 Windows 10 IoT 开发笔记:RTC 时钟模块 DS3231
- 张高兴的 Windows 10 IoT 开发笔记:ToF Sensor VL53L0X
- 张高兴的 Windows 10 IoT 开发笔记:RTC 时钟模块 DS3231
- 张高兴的 Windows 10 IoT 开发笔记:FM 电台模块 KT0803L
- 张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动数码管
- 张高兴的 Windows 10 IoT 开发笔记:DHT11 温湿度传感器
- 张高兴的 Windows 10 IoT 开发笔记:使用 Lightning 中的软件 PWM 驱动 RGB LED
- 张高兴的 Windows 10 IoT 开发笔记:使用 ULN2003A 控制步进电机
- 张高兴的 Windows 10 IoT 开发笔记:使用 ULN2003A 控制步进电机
- 张高兴的 Windows 10 IoT 开发笔记:三轴数字罗盘 HMC5883L
- 张高兴的 Windows 10 IoT 开发笔记:DHT11 温湿度传感器
- 张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动 8×8 点阵
- 张高兴的 Windows 10 IoT 开发笔记:BH1750FVI 光照度传感器
- 张高兴的 Windows 10 IoT 开发笔记:HC-SR04 超声波测距模块
- 张高兴的 Windows 10 IoT 开发笔记:0.96 寸 I2C OLED
- 《连载 | 物联网框架ServerSuperIO教程》-4.如开发一套设备驱动,同时支持串口和网络通讯。附:将来支持Windows 10 IOT
- 张高兴的 Windows 10 IoT 开发笔记:使用 ADS1115 读取模拟信号
- 张高兴的 Windows 10 IoT 开发笔记:使用 MAX7219 驱动 8×8 点阵
- 《物联网框架ServerSuperIO教程》-4.如开发一套设备驱动,同时支持串口和网络通讯。附:将来支持Windows 10 IOT
- 张高兴的 Windows 10 IoT 开发笔记:ADXL345 加速度传感器