Exit status 1 'calculateSum' was not declared in this scope

I really can't find anything that helps me get over this error.
It is embarrassing to admit to what might be a simple fix. If I am right to think that I must declare a variable before I use it. I understand the phraseology but how to implement it. I would like to know why this mistake is present where it is, in Hans-Petter Halvorsen's tutorials?
Help would be great...

Code, posted in code tags would be grand.

I hope this helps.....

const int arraysize = 100;
int x;
int sum = 0;
float average = 0;
int myarray[arraysize];

void setup()

void loop() 
      sum = 0;  
      for (int i = 0; i < arraysize; i++)
          x = random(200);
          myarray[i] = x;
      sum = calculateSum(myarray);
      average = sum / 100;
      Serial.print(" Sum = ");
      Serial.print(" , Average = ");
int calculateSum (int sumarray[])
for (int i = 0; i < arraysize; i++)
              sum = sum + sumarray[i];
    return sum;

1 Like


Found that spurious bracket. If I had my glasses on......

New error message:
avrdude: ser_open(): can't open device "\.\COM3": The semaphore timeout period has expired.

Where will it end?

Unplug your device, check which comports are available in the IDE. Plug your device in, does a new comport show up?

Com3 is being used Com 1, 3, 4 are empty. In addition to that error message I get this:

Problem uploading to board. See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.
processing.app.SerialException: Error opening serial port 'COM3'.
at processing.app.Serial.(Serial.java:152)
at processing.app.Serial.(Serial.java:82)
at processing.app.SerialMonitor$2.(SerialMonitor.java:132)
at processing.app.SerialMonitor.open(SerialMonitor.java:132)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2126)
at processing.app.Editor.access$1300(Editor.java:116)
at processing.app.Editor$UploadHandler.run(Editor.java:2095)
at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM3; Method name - openPort(); Exception type - Port busy.
at jssc.SerialPort.openPort(SerialPort.java:164)
at processing.app.Serial.(Serial.java:141)
... 8 more
Error opening serial port 'COM3'.
Error opening serial port 'COM3'. (Port busy)
Error opening serial port 'COM3'. (Port busy)
Error opening serial port 'COM3'. (Port busy)
Error opening serial port 'COM3'. (Port busy)

That last line is in a loop....

What do you mean by that? When you followed the instructions provided by Idahowalker, was COM3 the new prot that showed up after plugging in the Arduino board?

@cut-me-own-throat_dibbler, your topic has been moved to a more suitable location on the forum. Introductory Tutorials is for tutorials that e.g. you write, not for questions. Feel free to write a tutorial once you have solved your problem :wink: