0

我目前正在使用.net微型框架在Netduino Plus 2上執行一個項目,這需要我編寫脈衝傳感器。我試圖找到脈衝傳感器的代碼,但無濟於事。我嘗試使用模擬量輸入代碼來測量脈搏,但輸出值看起來不正確(儘管在傳感器附近沒有心跳,但仍有一個恆定的高值)。請指教!Netduino Plus 2的脈衝傳感器編碼出錯了

這裏是我的心跳傳感器電流代碼:

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的)

+0

這是無法回答的,因爲您的發佈代碼本質上沒有任何重要性,只是調用其他神祕代碼。你也沒有提供任何關於你嘗試*的具體佈線的細節。如果您遵循Arduino教程,請考慮使用Arduino構建和實驗,並且只有在詳細瞭解其工作原理後才嘗試移植它。 –

回答

0

很難說沒有你的脈搏設備以及它是如何附着在規格。對於我的最新項目模擬量輸入輸出&(https://github.com/osstekz/cncBuddy)我使用類InputPort & OutputPort(Microsoft.SPOT.Hardware) 例如:

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

...那麼喜歡你rate.Read();循環

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; 
    } 
+0

嗨,我添加了一個鏈接,顯示了我如何連接傳感器以及它的外觀。 – Sarahdonner