Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: AmbientLib SimpleIoTBoardLib mbed
main.cpp
00001 /* 00002 * Every 5 seconds, send the BPM value to Ambient. 00003 * Turn on and off the LED. 00004 */ 00005 #include "mbed.h" 00006 #include "math.h" 00007 #include "ESP8266Interface.h" 00008 #include "TCPSocketConnection.h" 00009 #include "SoftSerialSendOnry.h" 00010 #include "Ambient.h" 00011 00012 ESP8266Interface wifi(dp16,dp15,dp4,"ssid","password",115200); // TX,RX,Reset,SSID,Password,Baud 00013 00014 SoftSerialSendOnry pc(dp10); 00015 00016 unsigned int channelId = 100; 00017 const char* writeKey = "ライトキー"; 00018 Ambient ambient; 00019 00020 extern void interruptSetup(); 00021 00022 // Volatile Variables, used in the interrupt service routine! 00023 extern volatile bool QS; // becomes true when Arduoino finds a beat. 00024 extern volatile int BPM; // int that holds raw Analog in 0. updated every 2mS 00025 00026 int main() { 00027 TCPSocketConnection socket; 00028 00029 pc.baud(9600); 00030 00031 wifi.init(); //Reset 00032 wifi.connect(); //Use DHCP 00033 pc.printf("IP Address is %s\r\n", wifi.getIPAddress()); 00034 ambient.init(channelId, writeKey, &socket); 00035 00036 interruptSetup(); 00037 00038 while (true) { 00039 char bpmbuf[12]; 00040 00041 if (QS == true){ // A Heartbeat Was Found 00042 // BPM and IBI have been Determined 00043 // Quantified Self "QS" true when mbed finds a heartbeat 00044 sprintf(bpmbuf, "%3d", BPM); 00045 pc.printf("BPM:%s\r\n", bpmbuf); 00046 ambient.set(1, bpmbuf); 00047 ambient.send(); 00048 00049 QS = false; // reset the Quantified Self flag for next time 00050 } 00051 wait(5); // take a break 00052 } 00053 }
Generated on Fri Jul 15 2022 04:27:32 by
1.7.2