久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

標(biāo)題: MEGA2560主控自行車騎行監(jiān)測(cè)器源碼 [打印本頁(yè)]

作者: 水韻竹風(fēng)    時(shí)間: 2017-12-24 15:20
標(biāo)題: MEGA2560主控自行車騎行監(jiān)測(cè)器源碼
自行車騎行監(jiān)測(cè)器,可以GPS定位,檢測(cè)騎行速度,檢測(cè)心率,同時(shí)將以上數(shù)據(jù)寫(xiě)入SD卡內(nèi)進(jìn)行保存,使用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接一個(gè)LED顯示GPS是否工作正常

兩個(gè)霍爾傳感器接在外部中斷  Pin2 (interrupt 0), Pin3 (interrupt 1)

心跳指示燈在 Pin5   int fadePin = 5
int blinkPin = 14;               


單片機(jī)源程序如下:
  1. //#include"Arduino.h"
  2. //#include "AllSerialHanding.h"
  3. //#include "Interrupt.h"
  4. //#include "SD_ReadWrite.h"
  5. #include "all.h"
  6. #define PROCESSING_VISUALIZER 1
  7. #define SERIAL_PLOTTER  2
  8. volatile int BPM;                   // int that holds raw Analog in 0. updated every 2mS
  9. volatile int Signal;                // holds the incoming raw data
  10. volatile int IBI = 600;             // int that holds the time interval between beats! Must be seeded!
  11. static int outputType = SERIAL_PLOTTER;
  12. String beat_data = " BPM:0 IBI:0 Signal:0";

  13. void PulseSensor_SD_Write()
  14. {
  15.   SD_Write("test.txt",beat_data);  //脈沖數(shù)據(jù)寫(xiě)入SD卡中PulseSensor.txt文件
  16. }
  17. //  Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.
  18. void sendDataToSerial(char symbol, int data ){
  19.     Serial.print(symbol);
  20.     Serial.println(data);
  21.   }
  22. void serialOutput(){   // Decide How To Output Serial.
  23.   
  24.   switch(outputType){
  25.     case PROCESSING_VISUALIZER:
  26.       sendDataToSerial('S', Signal);     // goes to sendDataToSerial function
  27.       break;
  28.     case SERIAL_PLOTTER:  // open the Arduino Serial Plotter to visualize these data
  29.       Serial.print(BPM);
  30.       Serial.print(",");
  31.       Serial.print(IBI);
  32.       Serial.print(",");
  33.       Serial.println(Signal);
  34.       beat_data=" BPM:"+String(BPM)+" IBI:"+String(IBI)+" Signal:"+String(Signal);
  35.       
  36.       break;
  37.     default:
  38.       break;
  39.   }

  40. }

  41. //  Decides How To OutPut BPM and IBI Data
  42. void serialOutputWhenBeatHappens(){
  43.   switch(outputType){
  44.     case PROCESSING_VISUALIZER:    // find it here https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
  45.       sendDataToSerial('B',BPM);   // send heart rate with a 'B' prefix
  46.       sendDataToSerial('Q',IBI);   // send time between beats with a 'Q' prefix
  47.       break;

  48.     default:
  49.       break;
  50.   }
  51. }

  52. // SET THE SERIAL OUTPUT TYPE TO YOUR NEEDS
  53. // PROCESSING_VISUALIZER works with Pulse Sensor Processing Visualizer
  54. //      https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
  55. // SERIAL_PLOTTER outputs sensor data for viewing with the Arduino Serial Plotter
  56. //      run the Serial Plotter at 115200 baud: Tools/Serial Plotter or Command+L

  57. void ledFadeToBeat(){
  58.     fadeRate -= 15;                         //  set LED fade value
  59.     fadeRate = constrain(fadeRate,0,255);   //  keep LED fade value from going into negative numbers!
  60.     analogWrite(fadePin,fadeRate);          //  fade LED
  61.   }

  62. void Pulse_Init(){
  63.   pinMode(blinkPin,OUTPUT);         // pin that will blink to your heartbeat!
  64.   pinMode(fadePin,OUTPUT);          // pin that will fade to your heartbeat!
  65. //  Serial.begin(115200);             // we agree to talk fast!
  66.   interruptSetup();                 // sets up to read Pulse Sensor signal every 2mS
  67.    // IF YOU ARE POWERING The Pulse Sensor AT VOLTAGE LESS THAN THE BOARD VOLTAGE,
  68.    // UN-COMMENT THE NEXT LINE AND APPLY THAT VOLTAGE TO THE A-REF PIN
  69. //   analogReference(EXTERNAL);
  70. }


  71. //  Where the Magic Happens
  72. void Pulse_Allot(){

  73.     serialOutput() ;

  74.   if (QS == true){     // A Heartbeat Was Found
  75. ……………………

  76. …………限于本文篇幅 余下代碼請(qǐng)從51黑下載附件…………
復(fù)制代碼

所有資料51hei提供下載:
自行車騎行監(jiān)測(cè)器.zip (11.53 KB, 下載次數(shù): 10)










歡迎光臨 (http://www.zg4o1577.cn/bbs/) Powered by Discuz! X3.1
主站蜘蛛池模板: 久久国产精品一区二区三区 | 毛片免费在线 | 国产乱肥老妇国产一区二 | 在线观看视频你懂得 | 欧美精品一区二区三区在线播放 | 久久久久国| 亚洲成人激情在线观看 | 中文字幕免费中文 | 国产一级在线 | 中文字幕在线观看一区 | 精品二区 | 天天摸天天看 | 欧美日韩精品久久久免费观看 | 午夜无码国产理论在线 | 美日韩免费视频 | 99久久精品一区二区成人 | 狠狠操在线 | 日韩在线欧美 | 久久r精品 | 欧美久操网 | 久久艹av| 四虎国产 | 欧美一区二区三区精品 | 伊人性伊人情综合网 | 亚洲免费精品 | 91国产在线视频在线 | 男人影音 | 国产精品99 | 中文字幕第90页 | 性做久久久久久免费观看欧美 | 色接久久 | 五月天婷婷丁香 | 蜜桃黄网 | 中文字幕在线一区二区三区 | 国产福利在线播放 | 中文字幕av网站 | 国产剧情一区二区三区 | 国产精品久久久久久久久久尿 | 九九在线| 国产我和子的乱视频网站 | 中国黄色在线视频 |