/tmp/ccyfxzbU.ltrans0.ltrans.o: In function `main':
/home/builder/.arduino15/packages/arduino/hardware/avr/1.8.4/cores/arduino/main.cpp:43: undefined reference to `setup'
/home/builder/.arduino15/packages/arduino/hardware/avr/1.8.4/cores/arduino/main.cpp:46: undefined reference to `loop'
collect2: error: ld returned 1 exit status
Error during build: exit status 1
Here is the code:
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
char command;
void setup(1)
{
Serial.begin(9600); //Set the baudrate for Bluetooth module.
}
void loop(1){
if(Serial.available() > 0){
command = Serial.read();
Stop(); //initialize with motors stoped
//Serial.println(command);
switch(command){
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255);
motor1.run(BACKWARD); //rotate the motor counterclockwise
motor2.setSpeed(255);
motor2.run(BACKWARD); //rotate the motor counterclockwise
motor3.setSpeed(255);
motor3.run(BACKWARD); //rotate the motor counterclockwise
motor4.setSpeed(255);
motor4.run(BACKWARD); //rotate the motor counterclockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor counterclockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor counterclockwise
}
void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor counterclockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //turn motor1 off
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void Stop()
{
motor1.setSpeed(0);
motor2.run(RELEASE); //turn motor1 off
motor2.setSpeed(0);
motor2.run(RELEASE); //turn motor2 off
motor3.setSpeed(0);
motor3.run(RELEASE); //turn motor3 off
motor4.setSpeed(0);
motor4.run(RELEASE); //turn motor4 off
}
/tmp/ccoYvapZ.ltrans0.ltrans.o: In function `main':
/home/builder/.arduino15/packages/arduino/hardware/avr/1.8.4/cores/arduino/main.cpp:43: undefined reference to `setup'
/home/builder/.arduino15/packages/arduino/hardware/avr/1.8.4/cores/arduino/main.cpp:46: undefined reference to `loop'
collect2: error: ld returned 1 exit status
Error during build: exit status 1
Code:
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
char command;
void setup()
{
Serial.begin(9600); //Set the baudrate for Bluetooth module.
}
void loop(){
if(Serial.available() > 0){
command = Serial.read();
Stop(); //initialize with motors stoped
//Serial.println(command);
switch(command){
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255);
motor1.run(BACKWARD); //rotate the motor counterclockwise
motor2.setSpeed(255);
motor2.run(BACKWARD); //rotate the motor counterclockwise
motor3.setSpeed(255);
motor3.run(BACKWARD); //rotate the motor counterclockwise
motor4.setSpeed(255);
motor4.run(BACKWARD); //rotate the motor counterclockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor counterclockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor counterclockwise
}
void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor counterclockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //turn motor1 off
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void Stop()
{
motor1.setSpeed(0);
motor2.run(RELEASE); //turn motor1 off
motor2.setSpeed(0);
motor2.run(RELEASE); //turn motor2 off
motor3.setSpeed(0);
motor3.run(RELEASE); //turn motor3 off
motor4.setSpeed(0);
motor4.run(RELEASE); //turn motor4 off
}
I don't have any reason to think there is something about Arduino Cloud / Arduino Web Editor that would cause this.
I just gave it a try and was not able to reproduce the error. Does it still occur if you try it again now @easton1061?
If yes, I'm going to ask you to post some additional information that might help us to identify the problem.
NOTE: These instructions will not solve the problem. They are only intended to gather more information which might provide a clue that eventually leads to a solution.
Please do this:
From the menu on the left side of the "Arduino Web Editor" window, click "Preferences".
Check the box next to "☐ Always show output panel**".
Check the box next to "☐ Console: Show verbose output**".
In the sketch panel, click the (verify) button.
After the compilation fails, click the icon in the top right corner of the black console window at the bottom of the "Arduino Web Editor" window that looks like two pieces of paper.
In a forum reply here, click on the reply field.
Click the </> button on the forum toolbar.
This will add the forum's code block markup (```) to your reply to make sure the compilation output is correctly formatted.
Press Ctrl+V.
This will paste the compilation output between the code tags.
Move the cursor outside of the code tags before you add any additional text to your reply.
Click the Reply button to post the output.
In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:
Open a forum reply here by clicking the Reply button.
Click the "Upload" icon () on the post composer toolbar:
Select the .txt file you saved.
Click the Open button.
Click the Reply button to publish the post.
Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.