自行车骑行监测器,可以GPS定位,检测骑行速度,检测心率,同时将以上数据写入SD卡内进行保存,使用MEGA2560主控
SD卡的SPI接口 ** MOSI - pin 51 ** MISO - pin 50 ** CLK - pin 52 ** CS - pin 53
GPS的串口使用mega2560的串口1 Serial 1: Pin19 (RX) and Pin18 (TX);Pin13接一个LED显示GPS是否工作正常
两个霍尔传感器接在外部中断 Pin2 (interrupt 0), Pin3 (interrupt 1)
心跳指示灯在 Pin5 int fadePin = 5
int blinkPin = 14;
单片机源程序如下:
//#include"Arduino.h"
//#include "AllSerialHanding.h"
//#include "Interrupt.h"
//#include "SD_ReadWrite.h"
#include "all.h"
#define PROCESSING_VISUALIZER 1
#define SERIAL_PLOTTER 2
volatile int BPM; // int that holds raw Analog in 0. updated every 2mS
volatile int Signal; // holds the incoming raw data
volatile int IBI = 600; // int that holds the time interval between beats! Must be seeded!
static int outputType = SERIAL_PLOTTER;
String beat_data = " BPM:0 IBI:0 Signal:0";
void PulseSensor_SD_Write()
{
SD_Write("test.txt",beat_data); //脉冲数据写入SD卡中PulseSensor.txt文件
}
// Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.
void sendDataToSerial(char symbol, int data ){
Serial.print(symbol);
Serial.println(data);
}
void serialOutput(){ // Decide How To Output Serial.
switch(outputType){
case PROCESSING_VISUALIZER:
sendDataToSerial('S', Signal); // goes to sendDataToSerial function
break;
case SERIAL_PLOTTER: // open the Arduino Serial Plotter to visualize these data
Serial.print(BPM);
Serial.print(",");
Serial.print(IBI);
Serial.print(",");
Serial.println(Signal);
beat_data=" BPM:"+String(BPM)+" IBI:"+String(IBI)+" Signal:"+String(Signal);
break;
default:
break;
}
}
// Decides How To OutPut BPM and IBI Data
void serialOutputWhenBeatHappens(){
switch(outputType){
case PROCESSING_VISUALIZER: // find it here https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix
sendDataToSerial('Q',IBI); // send time between beats with a 'Q' prefix
break;
default:
break;
}
}
// SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS
// PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer
// https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
// SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter
// run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L
void ledFadeToBeat(){
fadeRate -= 15; // set LED fade value
fadeRate = constrain(fadeRate,0,255); // keep LED fade value from going into negative numbers!
analogWrite(fadePin,fadeRate); // fade LED
}
void Pulse_Init(){
pinMode(blinkPin,OUTPUT); // pin that will blink to your heartbeat!
pinMode(fadePin,OUTPUT); // pin that will fade to your heartbeat!
// Serial.begin(115200); // we agree to talk fast!
interruptSetup(); // sets up to read Pulse Sensor signal every 2mS
// IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
// UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
// analogReference(EXTERNAL);
}
// Where the Magic Happens
void Pulse_Allot(){
serialOutput() ;
if (QS == true){ // A Heartbeat Was Found
……………………
上一篇:ATmega8+PT100热敏电阻+AD824S proteus仿真与源程序
下一篇:avr单片机可演奏的电子琴仿真加源码
推荐阅读最新更新时间:2024-11-02 00:54
设计资源 培训 开发板 精华推荐
- LT3957EUHE、4.5V 至 16V 输入、24V 输出升压转换器的典型应用电路
- stm32视频小车驱动板
- 使用 Analog Devices 的 LTC3803ES6-3 的参考设计
- NCP300LSN44T1 4.4V 窗口电压检测器的典型应用
- 使用 Analog Devices 的 ADN2812 的参考设计
- 小汐 -> STM32 Mega Mini
- DC1813A-G,用于 LTC2367CMS-18、18 位、500 ksps、31MHz 低功率、低噪声模数转换器的演示板
- DC2293A-B,用于 LTC2933 DFN 编程板的演示板,用于具有 EEPROM 的可编程十六进制电压监控器
- 有源钳位正激AC-DC电源基础仿真电路
- 有颜值有内涵的Es9023-USBDAC
- ADI有奖下载活动之19:ADI可编程逻辑控制器(PLC)解决方案(更新版)
- 帮助他人,成就自己:EEWORLD月度问答榜(第6期)
- TI 有奖直播 | 毫米波雷达在楼宇自动化的应用
- MPS 送福利 | 商城上线送单,送京东卡,8000元好礼等你拿!
- Digi-Key KOL视频来袭~欢迎进入MicroPython的奇妙世界
- 【白皮书免费下载】施耐德电气三宝典:智能配电、关键电源,全生命周期服务
- 直播已结束【ST 宽禁带高性能碳化硅(SiC)与氮化镓(GaN)产品技术及不同应用案例分享】(9:30入场)
- 将想法变成现实,Maxim MAX32630FTHR创意设计大赛,重磅开启!
- 瓜分2000元新年开工红包!贸泽电子邀你元宵猜灯谜
- TI 嵌入式产品研讨会视频曝光,下载有礼!