BimoSora

arduino lcd temperatur heart rate

Jun 4th, 2020
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. #define USE_ARDUINO_INTERRUPTS true
  2. #define ONE_WIRE_BUS 2
  3. #include <DallasTemperature.h>
  4. #include <PulseSensorPlayground.h>
  5. #include <LiquidCrystal_I2C.h>
  6. #include <OneWire.h>
  7. #include <Wire.h>
  8. LiquidCrystal_I2C lcd(0x27,16,2);
  9.  
  10. const int PulseWire = 0;
  11. const int ledPin1 = LED_BUILTIN;
  12. const int ledPin2 = 12;
  13. int PulseSensorPurplePin = 0;
  14. int Signal;
  15. int Threshold = 550;
  16. int count = 0;
  17. int ledState1 = LOW;
  18. int ledState2 = LOW;
  19.  
  20. OneWire oneWire(ONE_WIRE_BUS);
  21. DallasTemperature sensors(&oneWire);
  22. PulseSensorPlayground pulseSensor;
  23.  
  24. unsigned long previousMillis1 = 0;
  25. unsigned long previousMillis2 = 0;
  26. unsigned long previousMillis3 = 0;
  27. unsigned long previousMillis4 = 0;
  28.  
  29. const long interval1 = 500;
  30. const long interval2 = 20;
  31. const long interval3 = 1000;
  32. const long interval4 = 750;
  33.  
  34. byte Colokan1[] = {
  35. B11111,
  36. B10001,
  37. B10001,
  38. B01110,
  39. B00100,
  40. B00100,
  41. B00100,
  42. B00100
  43. };
  44.  
  45. byte Kabel1[] = {
  46. B00100,
  47. B00100,
  48. B00100,
  49. B00100,
  50. B00100,
  51. B00100,
  52. B00100,
  53. B11100
  54. };
  55.  
  56. byte Kabel2[] = {
  57. B00000,
  58. B00000,
  59. B00000,
  60. B00000,
  61. B00000,
  62. B00000,
  63. B00000,
  64. B11111
  65. };
  66.  
  67. byte Kabel3[] = {
  68. B00000,
  69. B00000,
  70. B00000,
  71. B00000,
  72. B11100,
  73. B00100,
  74. B00100,
  75. B00111
  76. };
  77.  
  78. byte Power1[] = {
  79. B00000,
  80. B00000,
  81. B00000,
  82. B00000,
  83. B11111,
  84. B11111,
  85. B11111,
  86. B11111
  87. };
  88.  
  89. byte Temp1[] = {
  90. B01110,
  91. B01010,
  92. B01010,
  93. B01010,
  94. B01110,
  95. B11111,
  96. B11111,
  97. B01110
  98. };
  99.  
  100. byte Temp2[] = {
  101. B00110,
  102. B01001,
  103. B01001,
  104. B00110,
  105. B00000,
  106. B00000,
  107. B00000,
  108. B00000
  109. };
  110.  
  111. byte Heart1[] = {
  112. B00000,
  113. B01010,
  114. B11111,
  115. B11111,
  116. B11111,
  117. B01110,
  118. B00100,
  119. B00000
  120. };
  121.  
  122. void setup() {
  123. lcd.begin();
  124. lcd.backlight();
  125. sensors.begin();
  126. pulseSensor.analogInput(PulseWire);
  127. pulseSensor.setThreshold(Threshold);
  128. Serial.begin(9600);
  129. pinMode(ledPin1, OUTPUT);
  130. pinMode(ledPin2, OUTPUT);
  131.  
  132. lcd.createChar(0, Colokan1);
  133. lcd.createChar(1, Kabel1);
  134. lcd.createChar(2, Kabel2);
  135. lcd.createChar(3, Kabel3);
  136. lcd.createChar(4, Power1);
  137. lcd.createChar(5, Temp1);
  138. lcd.createChar(6, Temp2);
  139. lcd.createChar(7, Heart1);
  140. lcd.clear();
  141.  
  142. lcd.setCursor(6,0);
  143. lcd.write(byte(0));
  144. lcd.setCursor(7,0);
  145. lcd.print("ON");
  146. lcd.setCursor(6,1);
  147. lcd.write(byte(1));
  148. lcd.setCursor(5,1);
  149. lcd.write(byte(2));
  150. lcd.setCursor(4,1);
  151. lcd.write(byte(2));
  152. lcd.setCursor(3,1);
  153. lcd.write(byte(2));
  154. lcd.setCursor(2,1);
  155. lcd.write(byte(2));
  156. lcd.setCursor(1,1);
  157. lcd.write(byte(3));
  158. lcd.setCursor(0,1);
  159. lcd.write(byte(4));
  160. delay(3000);
  161. lcd.clear();
  162.  
  163. lcd.setCursor(0,0);
  164. lcd.print("GONIT SENSOR");
  165.  
  166. lcd.setCursor(0,1);
  167. lcd.print("VERSION 1.0");
  168. delay(3000);
  169. lcd.clear();
  170.  
  171. lcd.setCursor(0,0);
  172. lcd.write(byte(5));
  173. lcd.setCursor(2,0);
  174. lcd.print("0");
  175. lcd.write(byte(6));
  176. lcd.print("C");
  177.  
  178. if (pulseSensor.begin()) {
  179. lcd.setCursor(0,1);
  180. lcd.write(byte(7));
  181. lcd.setCursor(2,1);
  182. lcd.print("0");
  183. }
  184. delay(3000);
  185. }
  186.  
  187. void loop() {
  188. unsigned long currentMillis = millis();
  189.  
  190. if (currentMillis - previousMillis1 >= interval1) {
  191. previousMillis1 = currentMillis;
  192. sensors.requestTemperatures();
  193. lcd.setCursor(0,0);
  194. lcd.write(byte(5));
  195. lcd.setCursor(2,0);
  196. lcd.print(sensors.getTempCByIndex(0));
  197. lcd.write(byte(6));
  198. lcd.print("C");
  199. }
  200.  
  201. int myBPM = pulseSensor.getBeatsPerMinute();
  202. Signal = analogRead(PulseSensorPurplePin);
  203.  
  204. if (currentMillis - previousMillis2 >= interval2) {
  205. previousMillis2 = currentMillis;
  206. if (pulseSensor.sawStartOfBeat()) {
  207. lcd.setCursor(0,1);
  208. lcd.write(byte(7));
  209. lcd.setCursor(2,1);
  210. lcd.print(myBPM);
  211. Serial.println(myBPM);
  212. }
  213. }
  214.  
  215. if (currentMillis - previousMillis3 >= interval3) {
  216. previousMillis3 = currentMillis;
  217. if (ledState1 == LOW) {
  218. ledState1 = HIGH;
  219. } else {
  220. ledState1 = LOW;
  221. }
  222. digitalWrite(ledPin1, ledState1);
  223. }
  224.  
  225. if (currentMillis - previousMillis4 >= interval4) {
  226. previousMillis4 = currentMillis;
  227. if (ledState2 == LOW) {
  228. ledState2 = HIGH;
  229. } else {
  230. ledState2 = LOW;
  231. }
  232. digitalWrite(ledPin2, ledState2);
  233. }
  234. }
Add Comment
Please, Sign In to add comment