Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define USE_ARDUINO_INTERRUPTS true
- #define ONE_WIRE_BUS 2
- #include <DallasTemperature.h>
- #include <PulseSensorPlayground.h>
- #include <LiquidCrystal_I2C.h>
- #include <OneWire.h>
- #include <Wire.h>
- LiquidCrystal_I2C lcd(0x27,16,2);
- const int PulseWire = 0;
- const int ledPin1 = LED_BUILTIN;
- const int ledPin2 = 12;
- int PulseSensorPurplePin = 0;
- int Signal;
- int Threshold = 550;
- int count = 0;
- int ledState1 = LOW;
- int ledState2 = LOW;
- OneWire oneWire(ONE_WIRE_BUS);
- DallasTemperature sensors(&oneWire);
- PulseSensorPlayground pulseSensor;
- unsigned long previousMillis1 = 0;
- unsigned long previousMillis2 = 0;
- unsigned long previousMillis3 = 0;
- unsigned long previousMillis4 = 0;
- const long interval1 = 500;
- const long interval2 = 20;
- const long interval3 = 1000;
- const long interval4 = 750;
- byte Colokan1[] = {
- B11111,
- B10001,
- B10001,
- B01110,
- B00100,
- B00100,
- B00100,
- B00100
- };
- byte Kabel1[] = {
- B00100,
- B00100,
- B00100,
- B00100,
- B00100,
- B00100,
- B00100,
- B11100
- };
- byte Kabel2[] = {
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B00000,
- B11111
- };
- byte Kabel3[] = {
- B00000,
- B00000,
- B00000,
- B00000,
- B11100,
- B00100,
- B00100,
- B00111
- };
- byte Power1[] = {
- B00000,
- B00000,
- B00000,
- B00000,
- B11111,
- B11111,
- B11111,
- B11111
- };
- byte Temp1[] = {
- B01110,
- B01010,
- B01010,
- B01010,
- B01110,
- B11111,
- B11111,
- B01110
- };
- byte Temp2[] = {
- B00110,
- B01001,
- B01001,
- B00110,
- B00000,
- B00000,
- B00000,
- B00000
- };
- byte Heart1[] = {
- B00000,
- B01010,
- B11111,
- B11111,
- B11111,
- B01110,
- B00100,
- B00000
- };
- void setup() {
- lcd.begin();
- lcd.backlight();
- sensors.begin();
- pulseSensor.analogInput(PulseWire);
- pulseSensor.setThreshold(Threshold);
- Serial.begin(9600);
- pinMode(ledPin1, OUTPUT);
- pinMode(ledPin2, OUTPUT);
- lcd.createChar(0, Colokan1);
- lcd.createChar(1, Kabel1);
- lcd.createChar(2, Kabel2);
- lcd.createChar(3, Kabel3);
- lcd.createChar(4, Power1);
- lcd.createChar(5, Temp1);
- lcd.createChar(6, Temp2);
- lcd.createChar(7, Heart1);
- lcd.clear();
- lcd.setCursor(6,0);
- lcd.write(byte(0));
- lcd.setCursor(7,0);
- lcd.print("ON");
- lcd.setCursor(6,1);
- lcd.write(byte(1));
- lcd.setCursor(5,1);
- lcd.write(byte(2));
- lcd.setCursor(4,1);
- lcd.write(byte(2));
- lcd.setCursor(3,1);
- lcd.write(byte(2));
- lcd.setCursor(2,1);
- lcd.write(byte(2));
- lcd.setCursor(1,1);
- lcd.write(byte(3));
- lcd.setCursor(0,1);
- lcd.write(byte(4));
- delay(3000);
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.print("GONIT SENSOR");
- lcd.setCursor(0,1);
- lcd.print("VERSION 1.0");
- delay(3000);
- lcd.clear();
- lcd.setCursor(0,0);
- lcd.write(byte(5));
- lcd.setCursor(2,0);
- lcd.print("0");
- lcd.write(byte(6));
- lcd.print("C");
- if (pulseSensor.begin()) {
- lcd.setCursor(0,1);
- lcd.write(byte(7));
- lcd.setCursor(2,1);
- lcd.print("0");
- }
- delay(3000);
- }
- void loop() {
- unsigned long currentMillis = millis();
- if (currentMillis - previousMillis1 >= interval1) {
- previousMillis1 = currentMillis;
- sensors.requestTemperatures();
- lcd.setCursor(0,0);
- lcd.write(byte(5));
- lcd.setCursor(2,0);
- lcd.print(sensors.getTempCByIndex(0));
- lcd.write(byte(6));
- lcd.print("C");
- }
- int myBPM = pulseSensor.getBeatsPerMinute();
- Signal = analogRead(PulseSensorPurplePin);
- if (currentMillis - previousMillis2 >= interval2) {
- previousMillis2 = currentMillis;
- if (pulseSensor.sawStartOfBeat()) {
- lcd.setCursor(0,1);
- lcd.write(byte(7));
- lcd.setCursor(2,1);
- lcd.print(myBPM);
- Serial.println(myBPM);
- }
- }
- if (currentMillis - previousMillis3 >= interval3) {
- previousMillis3 = currentMillis;
- if (ledState1 == LOW) {
- ledState1 = HIGH;
- } else {
- ledState1 = LOW;
- }
- digitalWrite(ledPin1, ledState1);
- }
- if (currentMillis - previousMillis4 >= interval4) {
- previousMillis4 = currentMillis;
- if (ledState2 == LOW) {
- ledState2 = HIGH;
- } else {
- ledState2 = LOW;
- }
- digitalWrite(ledPin2, ledState2);
- }
- }
Add Comment
Please, Sign In to add comment