Hey I am working on a small project and I somehow managed to cause that setup is running more than once and on top of that new code won't upload to the board. I am not entirely sure what it is I've done wrong but I can't find answer so I am asking you guys.
void setup()
{
// put your setup code here, to run once:
Serial.begin(9600);
// I want to make some sound to tell the user to start measuring so I'll put some code below
Serial.print("Inicialize setup");
while (millis() < 5000)
{
if (millis() % 1000)
{
Serial.print(millis());
Serial.print("\n");
}
if (AnalogValue > MaxIntensity)
{
MaxIntensity = AnalogValue;
}
if (AnalogValue < MinIntensity)
{
MinIntensity = AnalogValue;
}
}
Serial.print("setup done");
float MaxDist = Distance(MaxIntensity);
float MinDist = Distance(MinIntensity);
float delta = MaxDist - fabs(MinDist);
Segmentlength = delta / 7;
for (int i = 7; i > 0; i--)
{
TonesUpperValues[i] = MinDist + (Segmentlength * i);
}
}
And this is the function used above
float Distance(int Intensity)
//function to calculate distance from intensity
{
float d = (1 / (exp(Intensity + EOffset))) + Offset;
d *= -1;
return d;
}
In serial monitor I see the millis being printed over and over and also some text which I am guessing is "inicialize setup"
and "Setup done"
When I try to upload the code this error appears:avrdude: ser_open(): can't open device "\\.\COM5": Access is denied.
even though : Auto-detected: COM5
Also previous code(the one that can't be overwritten by a new upload and is currently running had this warning in function that was not part of setup:src\main.cpp:38:1: warning: control reaches end of non-void function [-Wreturn-type]
Do you guys see any mistakes that I've made?