Hello
I have an ECG sensor that receives values between 50 and 100 I want to convert the VALUE of this section into a binary format I tried to convert, but I found it difficult to convert INT to string, what should i do ?
thank you.
const char LED = 13;
String msg_codee = "";
#define USE_ARDUINO_INTERRUPTS true
#include <PulseSensorPlayground.h>
// Variables
const int PulseWire = 0;
const int LED12 = 12;
int Threshold = 550;
PulseSensorPlayground pulseSensor;
void setup() {
Serial.begin(9600);
/************************************************************************************************/
pulseSensor.analogInput(PulseWire);
pulseSensor.blinkOnPulse(LED12);
pulseSensor.setThreshold(Threshold);
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !");
}
/************************************************************************************************/
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
}
void loop() {
/************************************************************************************************/
{
int myBPM = pulseSensor.getBeatsPerMinute();
if (pulseSensor.sawStartOfBeat()) {
Serial.println("♥ A HeartBeat Happened ! ");
Serial.print("BPM: ");
Serial.println(myBPM);
}
delay(20);
}
/*********************************************************************************************/
coding(); //transform the message received from pc into a binary sequence
}
//********************************** coding *********************************
void coding() {
String character = "";
int f = 0;
String msg_bin = myBPM;
Serial.print("bpm in bin :");
for (int i = 0; i < msg_bin.length(); i++) {
char myChar = msg_bin.charAt(i);
for (int j = 7; j >= 0; j--) {
byte bytes = bitRead(myChar, j);
Serial.print(bytes, BIN);
character += bytes;
}
}
Serial.println("");
msg_codee = character;
f++;
}
}// endof the coding
#1
i need to display the value of ecg sensor by binairy array for example if the ecg sensor give us value 78 i need to convert it to binairy foramt to sent it with ook modulation
light__fidelity:
I think you have the wrong idea of how that would work.... please post your OOK modulation code to understand better your intent
I have data from the ECG sensor, and I would like to convert these values into binary format,
This is the symbol for converting a text to a binary character, knowing that I enter the letters through the serial screen, but in my ideal, this is for the value sensor, it is not taken from the serial screen, but is taken directly from the sensor in the form of int, and that is why I found it difficult to convert it
light__fidelity:
I have data from the ECG sensor, and I would like to convert these values into binary format,
This is the symbol for converting a text to a binary character, knowing that I enter the letters through the serial screen, but in my ideal, this is for the value sensor, it is not taken from the serial screen, but is taken directly from the sensor in the form of int, and that is why I found it difficult to convert it