อุปกรณ์
- PIC16F877A microcontroller
- 20 Mhz Crystal
- 33pF capacitor 2 pcs
- 4.7k resistor 1 pcs
- 16x2 Character LCD
- 10K pot for contrast control of the LCD
- SEN-11574 Pulse sensor
- Velcro strap
- 5V Power adapter
- Breadboard and hookup wires
code
void main() { system_init(); main_state = READ_ADC; while (1) { switch (main_state) { case READ_ADC: { adc_value = ADC_Read(0); // 0 is the channel number main_state = CALCULATE_HEART_BEAT; break; } case CALCULATE_HEART_BEAT: { calculate_heart_beat(adc_value); main_state = SHOW_HEART_BEAT; break; } case SHOW_HEART_BEAT: { if (QS == true) { // A Heartbeat Was Found // BPM and IBI have been Determined // Quantified Self "QS" true when Arduino finds a heartbeat QS = false; // reset the Quantified Self flag for next time // 0.9 used for getting better data. actually should not be used BPM = BPM * 0.9; IBI = IBI / 0.9; lcd_com(0x80); lcd_puts("BPM:- "); lcd_print_number(BPM); lcd_com(0xC0); lcd_puts("I.B.I:- "); lcd_print_number(IBI); } } main_state = IDLE; break; case IDLE: { break; } default: { } } } }
อ้างอิง
ไม่มีความคิดเห็น:
แสดงความคิดเห็น