Go Down

Topic: Arduino/Genuino UNO R3 Board does not compile (Read 485 times) previous topic - next topic

VelariFox

Yes. But I can't find this library. If you have this library , give a link to the library or the library itself.

pert

Read it again very slowly and carefully. THERE IS NO MISSING LIBRARY!

VelariFox

 But you did not answer the question with this error:
 Arduino: 1.8.5 (Windows 10), Board:"Arduino/Arduino Uno"

C:\Users\Р°R°R\Desktop\Tehnic\Robototehnika\Programs\Remont\AFMotor_ConstantSpeed\AFMotor_ConstantSpeed.ino: In function 'void loop()':

AFMotor_ConstantSpeed:56: error: expected '}' at end of input

exit status 1
expected '}' at end of input

This report will have more information with
enabled file -> Settings ->
"Show verbose output during compilation"

In this sketch:


Code: [Select]
#include <AFMotor.h>
AF_DCMotor motorB(4); // подключаем мотор к клеммнику M4
AF_DCMotor motorA(3); // подключаем мотор к клеммнику M3

int val; // освобождаем память в контроллере

void setup() {

  Serial.begin(9600);
  motorB.setSpeed(250); // задаем максимальную скорость мотора
  motorB.run(RELEASE);  // останавливаем мотор
  motorA.setSpeed(250); // задаем максимальную скорость мотора
  motorA.run(RELEASE);  // останавливаем мотор
}

void loop() {

  if (Serial.available()) // проверяем, поступают ли какие-то команды
  {
    val = Serial.read();

    if (val == 'f') { // едем вперед
      motorB.run(FORWARD);
      motorB.setSpeed(250);
      motorA.run(FORWARD);
      motorA.setSpeed(250);
    }

    if (val == 'b') { // едем назад
      motorB.run(BACKWARD);
      motorB.setSpeed(200);
      motorA.run(BACKWARD);
      motorA.setSpeed(200);
    }

    if (val == 's') { // останавливаемся
      motorB.run(RELEASE);
      motorA.run(RELEASE);
    }

    if (val == 'l') { // поворачиваем налево
      motorB.run(FORWARD);
      motorB.setSpeed(100);
      motorA.run(BACKWARD);
      motorA.setSpeed(250);
    }

    if (val == 'r') { // поворачиваем направо
      motorB.run(BACKWARD);
      motorB.setSpeed(250);
      motorA.run(FORWARD);
      motorA.setSpeed(100);
   }   

pert

But you did not answer the question with this error:
 Arduino: 1.8.5 (Windows 10), Board:"Arduino/Arduino Uno"

C:\Users\Р°R°R\Desktop\Tehnic\Robototehnika\Programs\Remont\AFMotor_ConstantSpeed\AFMotor_ConstantSpeed.ino: In function 'void loop()':

AFMotor_ConstantSpeed:56: error: expected '}' at end of input

exit status 1
expected '}' at end of input
Yes, I did answer the question, as did sterretje:
Please read How to use this forum - please read, specifically point #7 how to post code.

It looks like you're missing some } at the end of the code; one to close the if (Serial.available()) and one to close loop().

If you use menu -> tools -> auto format in the IDE, the last } of the code should be at the beginning of a line.
You're still missing those closing braces sterretje told you about. If you look at the indentation that resulted from the auto format, it makes this clear.

Another useful feature of the Arduino IDE/Arduino Web Editor is that when you place the cursor next to one bracket, it puts a box around the matching bracket. In the Arduino IDE, if the cursor is next to the closing bracket and the opening bracket is off the screen then it will show the opening bracket line in a tool tip after a short delay.

Every { in your code must have a matching }.
It's frustrating when we take the time to try to help you and you won't even make the effort to read the answers we wrote. If there's something in the answer you don't understand, that's perfectly fine. You just need to explain which part you didn't understand and ask for clarification.

Go Up