Angular Speed with arduino

int pinLed = 13;
int buttonPin = 9;
String stringa;
char c;
unsigned long time1 = 0;
unsigned long time2 = 0;
unsigned long time3 = 0;
unsigned long time4 = 0;
int potentiometer = 0;
int potentiometer1 = 0;
int potentiometer2 = 0;
int val;
const int voltage = 5;
float angrad;
float angRad;
float velang


void setup() {
 Serial.begin(9600);
 pinMode(pinLed,OUTPUT);
 pinMode(buttonPin,INPUT);
 potentiometer = analogRead (A0);
}

void loop() {
 delay(10000);
 digitalWrite(pinLed,HIGH);
 if(Serial.available()){
   stringa="";
   do{
     if(Serial.available()){
       c=Serial.read();
       if(c != "\n")
         stringa+=c;
     }
   }while(c != "\n");

  if((stringa == "start")){
       
       digitalWrite(pinLed,LOW);
       time1 = millis();
       
   while ((digitalRead(buttonPin)==LOW)) {

       delay(12,5);
       tempo2 = millis();
       potentiometer1 = analogRead (A0);
       potentiometer2 = potentiometer1 - potentiometer;
       valore = map(potentiometer2,0,1023,0,5);
       angrad = (320*val)/voltage;
       angRad = map(angrad,0,320,0,6.283);
       time3 = time2 - time1;
       velang = angRad/time3;
       
       
     }
  
 
 }
}

Sorry for the misunderstanding :slight_smile: