I can't find this error on Google, please help

Hi all,

I just got the Arduino Uno starter kit as a gift, and have been trying to get the basic projects to work - however, I keep running into this error, no matter how simple my code is:

Command failed: C:\Users\HARALD~1\AppData\Local\Temp\build1451069086707\core.a(main.cpp.o): In function main': C:\Users\Haralds-pc\Desktop\Arduino\arduinostudio-0.0.5-win32\www\extensions\default\ArduinoStudioExt\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to loop' collect2.exe: error: ld returned 1 exit status

I have no idea what this means! I've been Googling and troubleshooting for hours and at this point would love some help.

Code:

void setup(){
    pinMode(3, OUTPUT);
    pinMode(2, INPUT);
}

You have to have a loop() function in any Arduino sketch.
The message says you haven't got one and indeed you haven't.

Pete

Thanks for the quick reply Supremo, but I'm having the problem even when the code does have a loop. Here's an example that I actually got to work, but then I started the next exercise in the book, and when I went back to this one it won't work anymore. Any ideas again?

Error Messages:

Command failed: C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp: In function 'void setup()': C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:44:6: error: redefinition of 'void setup()' void setup(){ ^ C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:9:6: error: 'void setup()' previously defined here void setup(){ ^ C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp: In function 'void loop()': C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:51:6: error: redefinition of 'void loop()' void loop(){ ^ C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:15:6: error: 'void loop()' previously defined here void loop(){ ^ C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:55:13: error: a function-definition is not allowed here before '{' token void setup(){ ^ C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:61:12: error: a function-definition is not allowed here before '{' token void loop(){ ^ C:\Users\HARALD~1\AppData\Local\Temp\build1451078722215\Project 2 - spaceship.cpp:87:1: error: expected '}' at end of input } ^

Code:

int switchState = 0;
void setup(){
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(3, OUTPUT);
    pinMode(2, INPUT);
}
void loop(){
    switchState = digitalRead(2);
        if (switchState == HIGH){
            delay(0);
            digitalWrite(5, HIGH);
            delay(200);
            digitalWrite(5, LOW);
            digitalWrite(4, HIGH);
            delay(200);
            digitalWrite(4, LOW);
            digitalWrite(3, HIGH);
            delay(200);
            digitalWrite(3, LOW);
        }
        else {
            delay(0);
            digitalWrite(3, HIGH);
            delay(200);
            digitalWrite(3, LOW);
            digitalWrite(4, HIGH);
            delay(200);
            digitalWrite(4, LOW);
            digitalWrite(5, HIGH);
            delay(200);
            digitalWrite(5, LOW);
        }
}

Here's a screenshot attached:

Furthermore, even if I completely clear the sketch of all code, and have a totally blank workspace, I still get this error:

[12/25/2015, 4:38:50 PM] - Start Building
[12/25/2015, 4:38:50 PM] - CPP File Created [C:\Users\HARALD~1\AppData\Local\Temp\build1451079530899\Untitled-1.cpp]
[12/25/2015, 4:38:50 PM] - Untitled-1.cpp compiled
[12/25/2015, 4:38:51 PM] - Command failed: C:\Users\HARALD~1\AppData\Local\Temp\build1451079530899\Untitled-1.cpp: In function 'void loop()': C:\Users\HARALD~1\AppData\Local\Temp\build1451079530899\Untitled-1.cpp:17:28: error: expected '}' at end of input Serial.print(sensorVal); ^

Where is it getting this void loop and serial.print from? The sketch area is 100% clear of code.

Thanks,

Eike

Is this the IDE you are using?

Hi CodingBadly,

Yes, I'm using that ArduinoStudio IDE.

I've read online about checking for multiple tabs being open, but I can't seem to find any tabs in this interface.

I hope I'm not derailing from the original topic, but I've noticed these kinds of errors also pop up when I copy and paste old code (which worked) into new, blank, scripts.

That's arduino.org (the rogue Arduino - there's ongoing legal action over the trademark).

Use the real ide - from the download link at the top of these forums. 1.6.5r5 is the most stable right now, I think. (1.6.6 added a really buggy new feature, and 1.6.7 only fixed subs if those bugs)