Click here to Skip to main content
15,886,045 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
#include <SoftwareSerial.h>
int PulseSensorPurplePin-0;
int Signal;
int Threshold - 550;
int S;
Softwareserial mySerial(10, 11);
void setup()
( pinMode (LED13, OUTPUT);
  Serial.begin(9600);
  mySerial.begin(9600); )
void loop()
( Signal = analogRead(PulseSensorPurplepin);
  S = (Signal / 8); Serial.print("Your heart Beat is : ");
  Serial.printIn(S);
  mySerial.printIn(S);
  if (Signal > Threshold)
  ( digitalWrite(LED13, HIGH);
  ) else
    (
      digitalWrite(LED13, LOW);
    )
    delay(1000);
  )


What I have tried:

can someone help me solve this problem ? thank you
Posted
Updated 12-Jul-22 20:11pm

Variable names cannot have '-' characters in them.
C
#include <SoftwareSerial.h>
int PulseSensorPurplePin-0;    <-- invalid name
int Signal;
int Threshold - 550;           <-- invalid name
int S;

These should be:
C
#include <SoftwareSerial.h>
int PulseSensorPurplePin;
int Signal;
int Threshold;
int S;
 
Share this answer
 
Comments
Shieka Alshehhi 16-Apr-22 21:09pm    
thank you , but i got a new error which says " initializer provided for function" for this line :
( pinMode (LED13, OUTPUT);
Dave Kreskowiak 16-Apr-22 21:31pm    
I didn't catch this before, but you're have parenthesis where curly braces should be:
#include <SoftwareSerial.h>
int PulseSensorPurplePin-0;
int Signal;
int Threshold - 550;
int S;
Softwareserial mySerial(10, 11);
void setup()
{
    pinMode (LED13, OUTPUT);
    Serial.begin(9600);
    mySerial.begin(9600);
}

void loop()
{
    Signal = analogRead(PulseSensorPurplepin);
    S = (Signal / 8);
    Serial.print("Your heart Beat is : ");
    Serial.printIn(S);
    mySerial.printIn(S);
    
    if (Signal > Threshold)
    {
        digitalWrite(LED13, HIGH);
    }
    else
    {
        digitalWrite(LED13, LOW);
    }

    delay(1000);
}


You REALLY need a beginners book on writing code for an Arduino. Both of these error are really easy to spot and fix.
CPallini 17-Apr-22 5:13am    
5."You REALLY need a beginners book on writing code for an Arduino. Both of these error are really easy to spot and fix"
Indeed.
Mostly considering that Arduino IDE does provide an application skeleton with curly braces at the right places...
#include <softwareserial.h>

int PulseSensorPurplePin = A0; //not =0 since you are reading Analog Value the value 0 for input pin is at Digital pin 0 "A0" is used instead
int Signal;
int Threshold = 550; //variable should be initialize this way i think
int S;
int LED13=13; //you should declare LED 13 if its connected to pin 13

SoftwareSerial mySerial(10, 11);

void setup(){
pinMode (LED13, OUTPUT);
Serial.begin(9600);
mySerial.begin(9600);

}

void loop(){
Signal = analogRead(PulseSensorPurplePin);

S = (Signal / 8);

Serial.print("Your heart Beat is : ");

Serial.println(S,DEC); //it should be Serial.println not Serial.printIn
mySerial.println(S,DEC); //the data type I think should also be declared as Decimal or DEC

if (Signal > Threshold){
digitalWrite(LED13, HIGH);
}
else{
digitalWrite(LED13, LOW);
}

delay(1000);
}


But I think this program does not provide a relevant heartbeat result since the code only reads analog value from A0 and compare it to a threshold. I think most heartbeat sensor runs on a one wire interface which is a digital type of data transmission serially.
 
Share this answer
 
v2
Comments
CHill60 13-Jul-22 7:46am    
The code
int PulseSensorPurplePin = A0;
results in the error "main.cpp:3:26: error: ‘A0’ was not declared in this scope"
bonezegei 13-Jul-22 7:55am    
Oh I found additional Errors

//This are typo errors from my code
SoftwareSerial mySerial(10, 11);
Signal = analogRead(PulseSensorPurplePin);


if that code was compiled with arduino
try checking if what board was set to your IDE this code will nost likely work uno mega Boards like arduino Uno and arduino mega..

If the board you chose was a different one refer to the pinout of the analog pin.. some boards does not have this type of pins thats why that type of error occurs..
bonezegei 13-Jul-22 7:57am    
#include <softwareserial.h>

int PulseSensorPurplePin = A0; //not =0 since you are reading Analog Value the value 0 for input pin is at Digital pin 0 "A0" is used instead
int Signal;
int Threshold = 550; //variable should be initialize this way i think
int S;
int LED13=13; //you should declare LED 13 if its connected to pin 13

SoftwareSerial mySerial(10, 11);

void setup(){
pinMode (LED13, OUTPUT);
Serial.begin(9600);
mySerial.begin(9600);

}

void loop(){
Signal = analogRead(PulseSensorPurplePin);

S = (Signal / 8);

Serial.print("Your heart Beat is : ");

Serial.println(S,DEC); //it should be Serial.println not Serial.printIn
mySerial.println(S,DEC); //the data type I think should also be declared as Decimal or DEC

if (Signal > Threshold){
digitalWrite(LED13, HIGH);
}
else{
digitalWrite(LED13, LOW);
}

delay(1000);
}
bonezegei 13-Jul-22 7:59am    
the code above works fine when i compiles it

but the board was set to an arduino uno
if the problem still exist even the board was set to AVR microcontroller try adding #include <arduino.h>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900