Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
4 Format code
source | link

I am trying to make an arduinoArduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

int sensorValue = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor
int count=0;count = 0;
unsigned long time1=0;time1 = 0;  // store the initial time
unsigned long time2;    // store the current time 
void setup() {
    // declare the ledPin as an OUTPUT:
    pinMode(sensorPin, INPUT); 
  
   Serial.begin(9600);
}

void loop() {
    // read the value from the sensor:
    if (count==0count == 0)
    {time1=millis
        time1 = millis();
    }
 time2=millis   time2 = millis();
    sensorValue = analogRead(sensorPin); 
    
 if (sensorValue>156sensorValue > 156)
    {
        increment();
    }
    if (time2>=time1+10000time2 >= time1 + 10000)
    {
        counter();
  }  }

}


void increment()
{
    count++;
    while (sensorValue>156sensorValue > 156)
    {
        Serial.print("Sensor value is greater than .75V\n");
    }
} 
void counter()
{ 
 count=count*6;   count = count * 6;
    Serial.print("Heart beat is ");
    Serial.print(count);
    Serial.print(" per min\n");
  time1=0;  time1 = 0;
  time2=0;  time2 = 0;
  count=0;  count = 0;
} 

Lines of code I'm not able to understand :

  if (count==0count == 0)
{
   {time1=millis time1 = millis();
    }
  time2 = time2=millismillis();
  sensorValue = analogRead(sensorPin);    
  if (sensorValue>156sensorValue > 156)
{
   { increment();
 }
if (time2 >= }
time1 + if(time2>=time1+1000010000)
{
   { counter();
    }

PS: the given code is in void loop(). in the beginning of the loop.

if u are not able to understand the code i'm leaving a link to the page:this is the link

i would be highly obliged if anyone could really help me soon. Thank u in advance :-)

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

int sensorValue = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor
int count=0;
unsigned long time1=0;  // store the initial time
unsigned long time2;    // store the current time 
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(sensorPin, INPUT);  
 Serial.begin(9600);
}

void loop() {
// read the value from the sensor:
if(count==0)
 {time1=millis();
  }
 time2=millis();
sensorValue = analogRead(sensorPin);    
 if(sensorValue>156)
  { increment();
   }
if(time2>=time1+10000)
 { counter();
  } 

}


void increment()
{count++;
 while(sensorValue>156)
  {Serial.print("Sensor value is greater than .75V\n");
   }
} 
void counter()
{ count=count*6;
  Serial.print("Heart beat is ");
  Serial.print(count);
  Serial.print(" per min\n");
  time1=0;
  time2=0;
  count=0;
} 

Lines of code I'm not able to understand :

  if(count==0)
   {time1=millis();
    }
    time2=millis();
  sensorValue = analogRead(sensorPin);    
  if(sensorValue>156)
   { increment();
    }
  if(time2>=time1+10000)
   { counter();
    }

PS: the given code is in void loop(). in the beginning of the loop.

if u are not able to understand the code i'm leaving a link to the page:this is the link

i would be highly obliged if anyone could really help me soon. Thank u in advance :-)

I am trying to make an Arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the given code .. specifically these few lines of code: The full code is given below:

int sensorValue = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor
int count = 0;
unsigned long time1 = 0;  // store the initial time
unsigned long time2;    // store the current time 
void setup() {
    // declare the ledPin as an OUTPUT:
    pinMode(sensorPin, INPUT); 
    Serial.begin(9600);
}

void loop() {
    // read the value from the sensor:
    if (count == 0)
    {
        time1 = millis();
    }
    time2 = millis();
    sensorValue = analogRead(sensorPin); 
    if (sensorValue > 156)
    {
        increment();
    }
    if (time2 >= time1 + 10000)
    {
        counter();
    }

}


void increment()
{
    count++;
    while (sensorValue > 156)
    {
        Serial.print("Sensor value is greater than .75V\n");
    }
}
void counter()
{ 
    count = count * 6;
    Serial.print("Heart beat is ");
    Serial.print(count);
    Serial.print(" per min\n");
    time1 = 0;
    time2 = 0;
    count = 0;
}

Lines of code I'm not able to understand :

if (count == 0)
{
    time1 = millis();
}
time2 = millis();
sensorValue = analogRead(sensorPin);
if (sensorValue > 156)
{
    increment();
}
if (time2 >= time1 + 10000)
{
    counter();
}

PS: the given code is in void loop(). in the beginning of the loop.

if u are not able to understand the code i'm leaving a link to the page:this is the link

i would be highly obliged if anyone could really help me soon. Thank u in advance :-)

3 added 1408 characters in body; edited tags
source | link

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

full code(PS:missing some function definition)

int sensorValue = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor
int count=0;
unsigned long time1=0;  // store the initial time
unsigned long time2;    // store the current time 
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(sensorPin, INPUT);  
Serial.begin(9600);
}

void loop() {
// read the value from the sensor:
if(count==0)
 {time1=millis();
  }
 time2=millis();
sensorValue = analogRead(sensorPin);    
if(sensorValue>156)
  { increment();
   }
if(time2>=time1+10000)
 { counter();
  } 

}


void increment()
{count++;
 while(sensorValue>156)
  {Serial.print("Sensor value is greater than .75V\n");
   }
} 
void counter()
{ count=count*6;
  Serial.print("Heart beat is ");
  Serial.print(count);
  Serial.print(" per min\n");
  time1=0;
  time2=0;
  count=0;
} 

Lines of code I'm not able to understand : code I'm not able to understand PS : it is void loop()

  if(count==0)
   {time1=millis();
    }
    time2=millis();
  sensorValue = analogRead(sensorPin);    
  if(sensorValue>156)
   { increment();
    }
  if(time2>=time1+10000)
   { counter();
    }

PS: the given code is in void loop(). in the beginning of the loop.

if u are not able to understand the code i'm leaving a link to the page:this is the link

i would be highly obliged if anyone could really help me soon. Thank u in advance :-)

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

full code(PS:missing some function definition)

Lines of code I'm not able to understand : code I'm not able to understand PS : it is void loop()

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

int sensorValue = 0;
int sensorValue = 0;  // variable to store the value coming from the sensor
int count=0;
unsigned long time1=0;  // store the initial time
unsigned long time2;    // store the current time 
void setup() {
// declare the ledPin as an OUTPUT:
pinMode(sensorPin, INPUT);  
Serial.begin(9600);
}

void loop() {
// read the value from the sensor:
if(count==0)
 {time1=millis();
  }
 time2=millis();
sensorValue = analogRead(sensorPin);    
if(sensorValue>156)
  { increment();
   }
if(time2>=time1+10000)
 { counter();
  } 

}


void increment()
{count++;
 while(sensorValue>156)
  {Serial.print("Sensor value is greater than .75V\n");
   }
} 
void counter()
{ count=count*6;
  Serial.print("Heart beat is ");
  Serial.print(count);
  Serial.print(" per min\n");
  time1=0;
  time2=0;
  count=0;
} 

Lines of code I'm not able to understand :

  if(count==0)
   {time1=millis();
    }
    time2=millis();
  sensorValue = analogRead(sensorPin);    
  if(sensorValue>156)
   { increment();
    }
  if(time2>=time1+10000)
   { counter();
    }

PS: the given code is in void loop(). in the beginning of the loop.

if u are not able to understand the code i'm leaving a link to the page:this is the link

i would be highly obliged if anyone could really help me soon. Thank u in advance :-)

2 deleted 932 characters in body
source | link

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor int count=0; unsigned long time1=0; // store the initial time unsigned long time2; // store the current time void setup() { // declare the ledPin as an OUTPUT: pinMode(sensorPin, INPUT);
Serial.begin(9600); }

void loop() { // read the value from the sensor: if(count==0) {time1=millis(); } time2=millis(); sensorValue = analogRead(sensorPin);
if(sensorValue>156) { increment(); } if(time2>=time1+10000) { counter(); }

} void increment() {count++; while(sensorValue>156) {Serial.print("Sensor value is greater than .75V\n"); } } void counter() { count=count*6; Serial.print("Heart beat is "); Serial.print(count); Serial.print(" per min\n"); time1=0; time2=0; count=0; } full code(PS:missing some function definition)

Lines of code I'm not able to understand :

if(count==0) {time1=millis(); } time2=millis(); sensorValue = analogRead(sensorPin);
if(sensorValue>156) { increment(); } if(time2>=time1+10000) { counter(); } code I'm not able to understand PS : it is void loop()

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

int sensorPin = A0; // select the input pin for the potentiometer int sensorValue = 0; // variable to store the value coming from the sensor int count=0; unsigned long time1=0; // store the initial time unsigned long time2; // store the current time void setup() { // declare the ledPin as an OUTPUT: pinMode(sensorPin, INPUT);
Serial.begin(9600); }

void loop() { // read the value from the sensor: if(count==0) {time1=millis(); } time2=millis(); sensorValue = analogRead(sensorPin);
if(sensorValue>156) { increment(); } if(time2>=time1+10000) { counter(); }

} void increment() {count++; while(sensorValue>156) {Serial.print("Sensor value is greater than .75V\n"); } } void counter() { count=count*6; Serial.print("Heart beat is "); Serial.print(count); Serial.print(" per min\n"); time1=0; time2=0; count=0; }

Lines of code I'm not able to understand :

if(count==0) {time1=millis(); } time2=millis(); sensorValue = analogRead(sensorPin);
if(sensorValue>156) { increment(); } if(time2>=time1+10000) { counter(); }

I am trying to make an arduino heart beat counter . I looked for some code online and found this code on arduino.cc forum but I couldn't understand working of the the given code .. specifically these few lines of code: The full code is given below:

full code(PS:missing some function definition)

Lines of code I'm not able to understand : code I'm not able to understand PS : it is void loop()

1
source | link