我目前正在使用 .net 微框架在 Netduino Plus 2 上做一个项目,这需要我为脉冲传感器编写代码。我曾尝试查找脉搏传感器的代码,但无济于事。我尝试对脉冲传感器使用 AnalogInput 代码,但输出值似乎错误(尽管传感器附近没有放置心跳,但输出值一直很高)。请指教!
这是我当前的心跳传感器代码:
using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.Netduino;
namespace heartrate
{
public class Program
{
public static void Main()
{
SecretLabs.NETMF.Hardware.AnalogInput rate =
new SecretLabs.NETMF.Hardware.AnalogInput(Pins.GPIO_PIN_A0);
int sensorvalue = 0;
while (true)
{
sensorvalue = rate.Read();
Debug.Print("" + sensorvalue);
Thread.Sleep(1000);
}
}
}
}
以下是传感器的规格、外观和连接方式。 http://www.elecrow.com/wiki/index.php?title=Pulse_Sensor (本教程适用于arduino,但我认为接线类似于Netduino)