How to integrate sine function in arduino

Hi, i need help

how ti integrate sine function in arduino?

Sum of minimum squares, show them in an int unsignet to add them and then do 1 / N?

Thanks

The integral over what range?

0 and 2*pi,

the signal is analogRead from source.

int tiempo=0;
float V1,V2,V3,V4,V5,V6,V7,deltaT=0.1,V2a;
float T=1e6/60.0,Vcc=0.8;
float V2ant,V10; 
int tiempo2=0,tiempo3=0;
void setup() {
  Serial.begin(9600);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);  
  pinMode(12,OUTPUT);
  pinMode(13,OUTPUT);
}
void loop() {
  deltaT=(micros()-tiempo);
  tiempo=micros();    
 // V1=sin(2*3.1416/T*micros());
 //  V1=analogRead(A0)*2/1023.0-1.0;

//  V2=analogRead(A0)*2/1023.0-1.0; // read the sin of source 60hz, the signal has a offset in the range 0-5v
  V2=cos(2*3.1416/T*micros());    // I assume the integral

 //   V2=(deltaT/1e6*V1+V2ant);
 //   V2a=-(V2*377-1);

  V3=1;// Detector de picos
  V4=V3+V2a;
  V5=V3-V2a;
  Vcc=analogRead(A1)/1023.0*5.0;
  V2ant=V2;
  if (V4>Vcc){
    V6=0;}else{V6=1;tiempo2=micros();}
  if (V5>Vcc){
    V7=0;}else{V7=1;tiempo3=micros();}
  if (V6==V7){if(tiempo2>tiempo3){V6=0;digitalWrite(13,LOW);V7=1;digitalWrite(12,HIGH);}else{V6=1;digitalWrite(13,HIGH);V7=0;digitalWrite(12,LOW);}}else{
  if(V6==1){digitalWrite(13,HIGH);}else{digitalWrite(13,LOW);};
  if(V7==1){digitalWrite(12,HIGH);}else{digitalWrite(12,LOW);}}
 Serial.print(V1+1);  Serial.print(" ");Serial.println(V2a+1);
//  deltaT=(micros()-tiempo);
}

First you would subtract the DC offset so the samples are signed. Edit - oh, you didn’t mention that you had code.

Yes i need subtrac the DC offset, i rest this offset in the code analogread.

It's been a while, but isn't the integral of sinx over the interval of 0-2pi equal to zero?

Yes, but i need integrate the funtion sin(wt) of the source AC 60HZ, to convert in cos(wt) funtion in continuios analog samplin.

Use dy/dt = x