Hi! I am doing a ecg project .In which I want 800 sensor reading at interval of 1ms for 800ms.After that I want to give delay of 800ms ,again want 800 sensor reading at interval of 1ms for 800ms and so on.But I am not getting desired output
Here is my code that I am writing on arduino ide but not getting the desired output.So please help me how can I get desired output.
Hereis code-
#include <EEPROM.h>
unsigned long previousMillis=0;
void setup() {
// initialize the serial communication:
Serial.begin(115200);
pinMode(10, INPUT); // Setup for leads off detection LO +
pinMode(11, INPUT); // Setup for leads off detection LO
}
unsigned long currentMillis;
void loop()
{
int t,i;
if((digitalRead(10)==1)||(digitalRead(11)==1))
{
Serial.println("!");
}else
{ for(i=0;i<800;i++)
{currentMillis=micros();
if(currentMillis-previousMillis>=1000)
{
previousMillis=currentMillis;
t=float(currentMillis)/1000;
Serial.print(t);
Serial.print(",");
Serial.println(analogRead(A0));}}}
delay(800);
}