Go Down

Topic: Erros com a programaçao (Read 154 times) previous topic - next topic

lucaszampieri

Jun 06, 2018, 12:36 am Last Edit: Jun 06, 2018, 01:02 am by surbyte
Me ajudem a resolver estes erros


Code: [Select]
#include <Ultrasonic.h>

#define ML_SPEED 5 // ENB
#define ML_FORWARD 6 // IN4
#define ML_BACKWARD 7 // IN3
#define MR_SPEED 10 // ENA
#define MR_FORWARD 9 // IN1
#define MR_BACKWARD 8 // IN2

#define CONFIG_PORT ()
pinMode(ML_FORWARD, OUTPUT);
pinMode(ML_BACKWARD, OUTPUT);
pinMode(MR_FORWARD, OUTPUT);
pinMode(MR_BACKWARD, OUTPUT);
#define MOVE_FRONT (sl, sr)
digitalWrite(ML_FORWARD, HIGH);
digitalWrite(ML_BACKWARD, LOW);
digitalWrite(MR_FORWARD, HIGH);
digitalWrite(MR_BACKWARD, LOW);
analogWrite(ML_SPEED, sl);
analogWrite(MR_SPEED, SR);

#define MOVE_BACK (sl, SR)
digitalWrite(ML_FORWARD, LOW);
digitalWrite(ML_BACKWARD, HIGH);
digitalWrite(MR_FORWARD, LOW);
digitalWrite(MR_BACKWARD, HIGH);
analogWrite(ML_SPEED, sl);
analogWrite(MR_SPEED, SR);

#define VEL0 0
#define VEL1 50
#define VEL2 100
#define VEL3 150
#define VEL4 200
#define VEL5 250

#define US_LEFT_VCC 8
#define US_LEFT_TRIG dois
#define US_LEFT_ECHO 13
#define US_RIGHT_TRIG A0
#define US_RIGHT_ECHO A1
#define US_RIGHT_GND A2

#define CONFIG_US ()
pinMode (US_LEFT_VCC, OUTPUT);
pinMode (US_RIGHT_GND, OUTPUT);
digitalWrite (US_LEFT_VCC, HIGH);
digitalWrite (US_RIGHT_GND, LOW);

//Ultra-sons USLeft (US_LEFT_TRIG, US_LEFT_ECHO);
//Ultra-sons USRight (US_RIGHT_TRIG, US_RIGHT_ECHO);

void setup ()
{
CONFIG_PORT ()
Serial.begin (9600);
CONFIG_US ();
}

void loop ()
{
int L_dist, R_dist;

L_dist = USLeft.Ranging (CM);
R_dist = USRight.Ranging (CM);
if (L_dist> 20 && R_dist> 20)
{
MOVE_FRONT (VEL3, VEL3);
}
if (L_dist <15)
{
MOVE_FRONT (VEL5, VEL0);
}
outro
if (R_dist <15)
{
MOVE_FRONT (VEL0, VEL5);
}
if (R_dist <10)
{
MOVE_BACK (VEL3, VEL0);
}
outro
if (L_dist <10)
{
MOVE_BACK (VEL0, VEL3) ;;
}
if (R_dist <10 && L_dist <10)
}



Erros

Code: [Select]
projeto_carrinho_novo:17: error: expected constructor, destructor, or type conversion before '(' token

pinMode(ML_FORWARD, OUTPUT);

       ^

projeto_carrinho_novo:18: error: expected constructor, destructor, or type conversion before '(' token

pinMode(ML_BACKWARD, OUTPUT);

       ^

projeto_carrinho_novo:19: error: expected constructor, destructor, or type conversion before '(' token

pinMode(MR_FORWARD, OUTPUT);

       ^

projeto_carrinho_novo:20: error: expected constructor, destructor, or type conversion before '(' token

pinMode(MR_BACKWARD, OUTPUT);

       ^

projeto_carrinho_novo:22: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(ML_FORWARD, HIGH);

            ^

projeto_carrinho_novo:23: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(ML_BACKWARD, LOW);

            ^

projeto_carrinho_novo:24: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(MR_FORWARD, HIGH);

            ^

projeto_carrinho_novo:25: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(MR_BACKWARD, LOW);

            ^

projeto_carrinho_novo:26: error: expected constructor, destructor, or type conversion before '(' token

analogWrite(ML_SPEED, sl);

           ^

projeto_carrinho_novo:27: error: expected constructor, destructor, or type conversion before '(' token

analogWrite(MR_SPEED, SR);

           ^

projeto_carrinho_novo:30: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(ML_FORWARD, LOW);

            ^

projeto_carrinho_novo:31: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(ML_BACKWARD, HIGH);

            ^

projeto_carrinho_novo:32: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(MR_FORWARD, LOW);

            ^

projeto_carrinho_novo:33: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite(MR_BACKWARD, HIGH);

            ^

projeto_carrinho_novo:34: error: expected constructor, destructor, or type conversion before '(' token

analogWrite(ML_SPEED, sl);

           ^

projeto_carrinho_novo:35: error: expected constructor, destructor, or type conversion before '(' token

analogWrite(MR_SPEED, SR);

           ^

projeto_carrinho_novo:57: error: expected constructor, destructor, or type conversion before '(' token

pinMode (US_LEFT_VCC, OUTPUT);

        ^

projeto_carrinho_novo:58: error: expected constructor, destructor, or type conversion before '(' token

pinMode (US_RIGHT_GND, OUTPUT);

        ^

projeto_carrinho_novo:59: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite (US_LEFT_VCC, HIGH);

             ^

projeto_carrinho_novo:60: error: expected constructor, destructor, or type conversion before '(' token

digitalWrite (US_RIGHT_GND, LOW);

             ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino: In function 'void setup()':

projeto_carrinho_novo:16: error: expected primary-expression before ')' token

#define CONFIG_PORT ()

                     ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:67:1: note: in expansion of macro 'CONFIG_PORT'

CONFIG_PORT ()

^

projeto_carrinho_novo:56: error: expected primary-expression before ')' token

#define CONFIG_US ()

                   ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:69:1: note: in expansion of macro 'CONFIG_US'

CONFIG_US ();

^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino: In function 'void loop()':

projeto_carrinho_novo:76: error: 'USLeft' was not declared in this scope

L_dist = USLeft.Ranging (CM);

         ^

projeto_carrinho_novo:76: error: 'CM' was not declared in this scope

L_dist = USLeft.Ranging (CM);

                         ^

projeto_carrinho_novo:77: error: 'USRight' was not declared in this scope

R_dist = USRight.Ranging (CM);

         ^

projeto_carrinho_novo:21: error: 'sl' was not declared in this scope

#define MOVE_FRONT (sl, sr)

                    ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:80:1: note: in expansion of macro 'MOVE_FRONT'

MOVE_FRONT (VEL3, VEL3);

^

projeto_carrinho_novo:21: error: 'sr' was not declared in this scope

#define MOVE_FRONT (sl, sr)

                        ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:80:1: note: in expansion of macro 'MOVE_FRONT'

MOVE_FRONT (VEL3, VEL3);

^

projeto_carrinho_novo:21: error: 'sl' was not declared in this scope

#define MOVE_FRONT (sl, sr)

                    ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:84:1: note: in expansion of macro 'MOVE_FRONT'

MOVE_FRONT (VEL5, VEL0);

^

projeto_carrinho_novo:21: error: 'sr' was not declared in this scope

#define MOVE_FRONT (sl, sr)

                        ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:84:1: note: in expansion of macro 'MOVE_FRONT'

MOVE_FRONT (VEL5, VEL0);

^

projeto_carrinho_novo:86: error: 'outro' was not declared in this scope

outro

^

projeto_carrinho_novo:29: error: 'sl' was not declared in this scope

#define MOVE_BACK (sl, SR)

                   ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:93:1: note: in expansion of macro 'MOVE_BACK'

MOVE_BACK (VEL3, VEL0);

^

projeto_carrinho_novo:29: error: 'SR' was not declared in this scope

#define MOVE_BACK (sl, SR)

                       ^

C:\Users\Admin\Desktop\projeto_carrinho_novo\projeto_carrinho_novo.ino:93:1: note: in expansion of macro 'MOVE_BACK'

MOVE_BACK (VEL3, VEL0);

^

projeto_carrinho_novo:96: error: expected ';' before 'if'

if (L_dist <10)

^

projeto_carrinho_novo:101: error: expected primary-expression before '}' token

}

^

exit status 1
expected constructor, destructor, or type conversion before '(' token




luisilva

As partes seguintes do código devem estar dentro de uma função, por exemplo a função setup():
Code: [Select]
pinMode(ML_FORWARD, OUTPUT);
pinMode(ML_BACKWARD, OUTPUT);
pinMode(MR_FORWARD, OUTPUT);
pinMode(MR_BACKWARD, OUTPUT);


Code: [Select]
digitalWrite(ML_FORWARD, HIGH);
digitalWrite(ML_BACKWARD, LOW);
digitalWrite(MR_FORWARD, HIGH);
digitalWrite(MR_BACKWARD, LOW);
analogWrite(ML_SPEED, sl);
analogWrite(MR_SPEED, SR);


Code: [Select]
digitalWrite(ML_FORWARD, LOW);
digitalWrite(ML_BACKWARD, HIGH);
digitalWrite(MR_FORWARD, LOW);
digitalWrite(MR_BACKWARD, HIGH);
analogWrite(ML_SPEED, sl);
analogWrite(MR_SPEED, SR);


Code: [Select]
pinMode (US_LEFT_VCC, OUTPUT);
pinMode (US_RIGHT_GND, OUTPUT);
digitalWrite (US_LEFT_VCC, HIGH);
digitalWrite (US_RIGHT_GND, LOW);


A linha seguinte não é um instrução válida:
Code: [Select]
outro

Para que são os 2 ';;'?
Code: [Select]
MOVE_BACK (VEL0, VEL3) ;;

Falta qualquer coisa depois deste if:
Code: [Select]
if (R_dist <10 && L_dist <10)
}


Penso que não tem as chavetas emparelhadas.

Go Up