Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <Wire.h>
  2. #include "MAX30105.h"
  3.  
  4. MAX30105 particleSensor; // initialize MAX30102 with I2C
  5.  
  6. void setup()
  7. {
  8. Serial.begin(115200);
  9. while(!Serial); //We must wait for Teensy to come online
  10. delay(100);
  11. Serial.println("");
  12. Serial.println("MAX30102");
  13. Serial.println("");
  14. delay(100);
  15. // Initialize sensor
  16. if (particleSensor.begin(Wire, I2C_SPEED_FAST) == false) //Use default I2C port, 400kHz speed
  17. {
  18. Serial.println("MAX30105 was not found. Please check wiring/power. ");
  19. while (1);
  20. }
  21.  
  22. byte ledBrightness = 70; //Options: 0=Off to 255=50mA
  23. byte sampleAverage = 1; //Options: 1, 2, 4, 8, 16, 32
  24. byte ledMode = 2; //Options: 1 = Red only, 2 = Red + IR, 3 = Red + IR + Green
  25. int sampleRate = 400; //Options: 50, 100, 200, 400, 800, 1000, 1600, 3200
  26. int pulseWidth = 69; //Options: 69, 118, 215, 411
  27. int adcRange = 16384; //Options: 2048, 4096, 8192, 16384
  28.  
  29. particleSensor.setup(ledBrightness, sampleAverage, ledMode, sampleRate, pulseWidth, adcRange); //Configure sensor with these settings
  30. }
  31.  
  32. void loop() {
  33. particleSensor.check(); //Check the sensor
  34. while (particleSensor.available()) {
  35. // read stored IR
  36. Serial.print(particleSensor.getFIFOIR());
  37. Serial.print(",");
  38. // read stored red
  39. Serial.println(particleSensor.getFIFORed());
  40. // read next set of samples
  41. particleSensor.nextSample();
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement