PULSE_SENSOR_LCD16X2

Dependencies:   PulseSensor TextLCD_AND_PULSE_SENSOR

Committer:
EDISON_NGUNJIRI
Date:
Wed Feb 23 18:44:39 2022 +0000
Revision:
2:6f02822e170d
Parent:
1:52ef36eb7a73
PULSE_SENSOR_LCD16X2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nprobably 0:8d3802709c6c 1 #include "mbed.h"
nprobably 0:8d3802709c6c 2 #include "PulseSensor.h"
EDISON_NGUNJIRI 1:52ef36eb7a73 3 #include "TextLCD.h"
EDISON_NGUNJIRI 1:52ef36eb7a73 4 #include <stdio.h>
EDISON_NGUNJIRI 1:52ef36eb7a73 5 #include <string.h>
EDISON_NGUNJIRI 1:52ef36eb7a73 6
EDISON_NGUNJIRI 1:52ef36eb7a73 7 void count();
EDISON_NGUNJIRI 1:52ef36eb7a73 8 DigitalIn Press(PB_5);
EDISON_NGUNJIRI 1:52ef36eb7a73 9 TextLCD lcd(PA_5, PA_6, PA_7, PA_8, PA_9, PA_10);// RS, E, D4-D7, LCDType=LCD16x2, BL=NC, E2=NC, LCDTCtrl=HD44780
EDISON_NGUNJIRI 1:52ef36eb7a73 10 InterruptIn button(PC_13);
EDISON_NGUNJIRI 1:52ef36eb7a73 11
EDISON_NGUNJIRI 1:52ef36eb7a73 12 int rate,Press_Count=0;
nprobably 0:8d3802709c6c 13 void sendDataToProcessing(char symbol, int data)
nprobably 0:8d3802709c6c 14 {
EDISON_NGUNJIRI 1:52ef36eb7a73 15 if(symbol == 'B') {
EDISON_NGUNJIRI 1:52ef36eb7a73 16 rate=data;
EDISON_NGUNJIRI 1:52ef36eb7a73 17 }
EDISON_NGUNJIRI 1:52ef36eb7a73 18
nprobably 0:8d3802709c6c 19 }
EDISON_NGUNJIRI 1:52ef36eb7a73 20 int main()
EDISON_NGUNJIRI 1:52ef36eb7a73 21 {
EDISON_NGUNJIRI 1:52ef36eb7a73 22 button.rise(&count);
nprobably 0:8d3802709c6c 23 PulseSensor sensor(A0, sendDataToProcessing);
EDISON_NGUNJIRI 1:52ef36eb7a73 24 pc.baud(9600);
nprobably 0:8d3802709c6c 25 sensor.start();
nprobably 0:8d3802709c6c 26 while(1) {
EDISON_NGUNJIRI 1:52ef36eb7a73 27 lcd.cls() ; // clear screen
EDISON_NGUNJIRI 1:52ef36eb7a73 28 lcd.locate(0,0);
EDISON_NGUNJIRI 1:52ef36eb7a73 29 lcd.printf("PULSE RATE=%d",rate);
EDISON_NGUNJIRI 1:52ef36eb7a73 30 lcd.locate(0,1);
EDISON_NGUNJIRI 1:52ef36eb7a73 31 lcd.printf("PRESS COUNT=%d ",Press_Count);
EDISON_NGUNJIRI 1:52ef36eb7a73 32 wait(1) ; // wait for 2s
EDISON_NGUNJIRI 1:52ef36eb7a73 33
nprobably 0:8d3802709c6c 34 }
nprobably 0:8d3802709c6c 35 }
EDISON_NGUNJIRI 1:52ef36eb7a73 36 void count()
EDISON_NGUNJIRI 1:52ef36eb7a73 37 {
EDISON_NGUNJIRI 1:52ef36eb7a73 38 Press_Count++;;
EDISON_NGUNJIRI 1:52ef36eb7a73 39 }