Advertisement
microrobotics

AD8232 Heart Rate Monitor Plot ECG to Arduino Serial Plotter

Apr 18th, 2023
1,397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Here's code for the AD8232 Heart Rate Monitor Kit that sends ECG data to the Serial Plotter:
  3.  
  4. After uploading the code to your Arduino board, open the Serial Plotter from the Arduino IDE by going to "Tools" > "Serial Plotter". You'll see the ECG graph in real-time. Adjust the delay in the loop() function to change the sampling rate.
  5.  
  6. Note that the Serial Plotter in the Arduino IDE is a basic tool for visualizing data. If you need more advanced features or want to store the ECG data for further analysis, consider using a more powerful plotting software like Processing or sending the data to a web server and plotting it using JavaScript libraries like Chart.js or Plotly.js.
  7. */
  8.  
  9. // Define the pin connections
  10. const int AD8232_LO_PLUS = 2;
  11. const int AD8232_LO_MINUS = 3;
  12. const int AD8232_OUTPUT = A0;
  13.  
  14. void setup() {
  15.   Serial.begin(9600);
  16.   pinMode(AD8232_LO_PLUS, INPUT);
  17.   pinMode(AD8232_LO_MINUS, INPUT);
  18.   pinMode(AD8232_OUTPUT, INPUT);
  19. }
  20.  
  21. void loop() {
  22.   int LO_plus = digitalRead(AD8232_LO_PLUS);
  23.   int LO_minus = digitalRead(AD8232_LO_MINUS);
  24.  
  25.   if (LO_plus == 1 || LO_minus == 1) {
  26.     Serial.println("Leads Off");
  27.   } else {
  28.     int output = analogRead(AD8232_OUTPUT);
  29.     Serial.println(output);
  30.   }
  31.  
  32.   delay(5); // Adjust the delay for different sampling rates
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement