Victor Karthik / Mbed 2 deprecated STM32Disco_Melexis

Dependencies:   mbed

main.cpp

Committer:
vctkarthik
Date:
2020-02-04
Revision:
0:7a2e98bb27f5
Child:
1:0624feb5a279

File content as of revision 0:7a2e98bb27f5:

#include "mbed.h"

/*  for the button press device should start reading, then it should stop the loop for button press  */

AnalogIn analog_value(A0);
InterruptIn  button(PA_0);
DigitalOut myled(LED1);
bool workState= false;
 
 
void read_ecg(bool work)
{
    float meas_r;
    float meas_v;
    
    if(work){
           meas_r = analog_value.read(); // Read the analog input value (value from 0.0 to 1.0 = full ADC conversion range)
           meas_v = meas_r * 3300; // Converts value in the 0V-3.3V range
        
          // Display values
           printf("measure = %f = %.0f mV\n", meas_r, meas_v);
        }
    
  
    
    
}
 
void toggle()
{
       myled = !myled; 
       workState = !workState;
       
        
    
        
}
        


int main() {
    
    button.rise(&toggle) ;
    while(1)
    {
        
      button.rise(&toggle) ;
      read_ecg(workState);
      
      wait(1);
        }
   
    
    
}