-1

I'm currently doing a project on Netduino Plus 2 using .net micro framework which requires me to code for a pulse sensor. I have tried finding codes for pulse sensor but to no avail. I tried using AnalogInput codes for pulse sensor but the output values seemed wrong (there was a constant high value despite no heartbeat placed near the sensor). Please advise!

Here are my current codes for the heartbeat sensor:

  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);
    }
   }
 }
 }

Here are the specs of the sensor, how it looks like and how it is connected. http://www.elecrow.com/wiki/index.php?title=Pulse_Sensor (This tutorial is for arduino, but I think the wiring is similar to that of Netduino)

10 Rep
  • 2,217
  • 7
  • 19
  • 33
Sarahdonner
  • 1
  • 1
  • 1
  • 4
  • This is unanswerable as your posted code essentially does nothing of importance, but merely invokes other mystery code. Nor have you provided any details about the specific wiring *of your attempt*. If you are following an Arduino tutorial, consider building and experimenting with that with an Arduino and only try to port it once you understand in detail how it works. – Chris Stratton Dec 05 '16 at 14:26

1 Answers1

0

Hard to tell without specs on your pulse device and how it is attached. For Analog input & output in my latest project (https://github.com/osstekz/cncBuddy) I use classes InputPort & OutputPort (Microsoft.SPOT.Hardware) ex:

public NESControllerAdapter(Cpu.Pin pinClk, Cpu.Pin pinLatch, Cpu.Pin pinData1/*, Cpu.Pin pinData2 = Cpu.Pin.GPIO_NONE*/) {
        // Binds to all pins
        this._outpClk = new OutputPort(pinClk, false);
        this._outpLatch = new OutputPort(pinLatch, false);
        this._inpData1 = new InputPort(pinData1, false, Port.ResistorMode.Disabled);
        //if (pinData2 != Cpu.Pin.GPIO_NONE) this._inpData2 = new InputPort(pinData2, false, Port.ResistorMode.Disabled);
        }

...then like your rate.Read(); loop

public int ButtonPressed() {
    // Locks all parms
    this._PinTick(this._outpLatch);

    // Reads plug state value
    for (int i = 0; i < CncBuddyShared.iTOTALNESCONTROLLERBUTTONS; ++i) {
        // Read the value, if true return this index as the first pressed button
        if (this._inpData1.Read() == false) return i;

        // Selects the next value
        this._PinTick(this._outpClk);
        }
    return NESCONTROLLER_PRESSEDBUTTOM_NONE;
    }
George Aslanis
  • 517
  • 4
  • 11