Projet_BMC / Mbed 2 deprecated PulseSensor2

Dependencies:   mbed USBDevice

Files at this revision

API Documentation at this revision

Comitter:
the_nabil
Date:
Tue Jan 21 16:04:23 2020 +0000
Parent:
0:030060e88177
Commit message:
pulsesensor

Changed in this revision

PulseSensor.cpp Show annotated file Show diff for this revision Revisions of this file
USBDevice.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/PulseSensor.cpp	Thu May 31 21:45:15 2018 +0000
+++ b/PulseSensor.cpp	Tue Jan 21 16:04:23 2020 +0000
@@ -34,7 +34,7 @@
 
 void PulseSensor::sensor_ticker_callback(void)
 {
-    Signal = 1023 * _pAin->read();              // read the Pulse Sensor
+    Signal = 3300 * _pAin->read();              // read the Pulse Sensor
     
     
     sampleCounter += 4;                         // keep track of the time in mS with this variable
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jan 21 16:04:23 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#53949e6131f6
--- a/main.cpp	Thu May 31 21:45:15 2018 +0000
+++ b/main.cpp	Tue Jan 21 16:04:23 2020 +0000
@@ -1,54 +1,65 @@
 #include "mbed.h"
 #include "PulseSensor.h"
+#include "USBSerial.h"
 
-Serial pc(USBTX, USBRX);
-DigitalOut led(D12);
+USBSerial pc;
+DigitalOut led(PC_8);
 PulseSensor sensor;
-InterruptIn button(USER_BUTTON);
+InterruptIn button(PC_13);
 
 int result;
 int len = 20;
-int values,count,trash;
+int values;
+int count;
+int trash;
 int myBPM;
 
+
 void pressed(){
     pc.printf("Your data are been sent\r\n");
 }
  
 void sendDataToProcessing(char symbol, int data){
     if(symbol == 'B') {
-        if(count<len){
+        if(::count<len){
             result = data<50?50:(data>120?120:data);
             //pc.printf("\rLoading");
-            count++;
+            ::count++;
             //for(int i=0;i<(j%4);++i) pc.printf(" .");
             if(result<51 || result >119) trash++;
             else    values+=result;
     
         }
-        if(count==len){
+        if(::count==len){
             myBPM=values/(len-trash);
             if(myBPM == 0){//if the result is composed only 
                 pc.printf("\rOps, something was wrong, I restart the measurement\r\n");
-                 led=0;count=0;values=0;trash=0;
+                 led=0; ::count=0;values=0;trash=0;
             }
             else{
                 led = 1;
                 pc.printf("\rYour average BPM are: %d\r\n[Black]\trestart the measurement\r\n[Blue]\tconfirm the data\r\n",myBPM);
                 button.fall(&pressed);
-                count++;
+                ::count++;
             }
         }
     }    
 }
 
+
 int main() {
-    pc.baud(115200);
+    //pc.baud(115200);
+    wait(1);
+    
     pc.printf("\r\n+++++++++++++++++++++++++++++++++++++++++++++++");    
-    pc.printf("\r\nStart to inizialize the process\n");
-    led=0;count=0;trash=0;values=0;
-    PulseSensor sensor(A0, sendDataToProcessing);
+    pc.printf("\r\nStart to initialize the process\n");
+    
+    
+    led=0; ::count=0; trash=0; values=0;
+    PulseSensor sensor(A1, sendDataToProcessing);
     while(1) {
         sensor.start();
+        wait(1);
     }
+    
 }
\ No newline at end of file
--- a/mbed.bld	Thu May 31 21:45:15 2018 +0000
+++ b/mbed.bld	Tue Jan 21 16:04:23 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/5aab5a7997ee
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file