I dont understand this error

Hello !

First, im spanish, and i dont speak (or write) english well… but i want to try to “chat” with you.

I have a code, from a radar with a lcd screen. I think all is ready but i have an error that i dont know.

The code is:


#include <LiquidCrystal.h>
#define recorrido 50
#define radar 13
#define MAX 50
unsigned long int tiemposensor1, tiemposensor2; // declara las variables
long int TiempoReal;
int x,x2;
int distancia = 400;
int sensor1 = 0;
int sensor2 = 1;
float velocidad;

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2); // se eligen las patillas que controlan el LCD
void setup (){
Serial.begin(9600); // velocidad de transmisión 9600 Baudios
pinMode (sensor1, INPUT); // sensor 1 y 2 como entradas.
pinMode (sensor2, INPUT);
pinMode (radar , OUTPUT); // Salida de radar
}
void loop (){
x= analogRead (sensor1); // lee el sensor 1 hasta que la distancia sea menor a la seleccionada
do{
x = analogRead (sensor1);
}while (x < tiemposensor1 =" millis();" x2 =“analogRead” x2 =" analogRead" tiemposensor2 =" millis();" tiemporeal =" (Tiemposensor2" velocidad =" ((0.1" velocidad =" espacio/"> MAX){ //si la velocidad es mayor a la velocidad maxima predefinida
digitalWrite (radar , HIGH); //el radar se activa
delay (200);
digitalWrite (radar , LOW);
Serial.print("Velocidad excesiva…RADAR ON "); //mensaje en la pantalla de PC
Serial.println(velocidad);
lcd.clear();
lcd.home();
lcd.print(“RADAR ON!!!”); //mensaje en el LCD
delay (500);
}
}


And the error says:

Radar_arduino.cpp: In function ‘void loop()’:
Radar_arduino:23: error: lvalue required as left operand of assignment
Radar_arduino:23: error: expected )' before 'x2' Radar_arduino:23: error: expected ;’ before ‘x2’
Radar_arduino:23: error: invalid conversion from ‘const char*’ to ‘int’
Radar_arduino:23: error: expected `;’ before ‘x2’


What i need to do??? I modify the “while” 1 hundred ¿times?, and never run.

Can you help me?

If not, no problem, thanks anyway !!!

Jorge G.

while (x < tiemposensor1 =" millis();" x2 ="analogRead" x2 =" analogRead" tiemposensor2 =" millis();" tiemporeal =" (Tiemposensor2" velocidad =" ((0.1" velocidad =" espacio/"> MAX){ //si la velocidad es mayor a la velocidad maxima predefinida

I’m guessing it got upset about that.

What are all those " marks doing?

the teacher put the " marks trying to run my program (unsuccessfully).

I dont touch this marks thinking that the teacher was better.

The while works making the sensor comparation operation.

Well, the teacher doesn't know better. It looks a really complicated condition, but it is syntactically incorrect. Very incorrect. Maybe you (or teacher) can explain what is supposed to happen.

The sensor 1 read a signal and save “old millis”.

The sensor 2 read a signal and save “new millis”.

The real time => new millis - old millis = space/speed

And compare.

MAYBE this code is soooooo difficult to me.

I try to do a simple example of the idea of the radar to understand (¿or know?) better the programming, to go step by step. I think that i would try to complete this to understand the other later. Same idea, but simple (no lcd sensor, only led to simulate the radar working)

-Only 2 sensor and a led. If the speed is more than assigned, red led lights. If the speed is lower than assigned, green led lights). Space (sensors) 0,5 meters. For the example, 50km/h limit

unsigned long millis();
unsigned long millis_actuales();
unsigned long millis_anteriores();
float v; //(the speed)
float e; // (the space)
insigned long T; // (the time)

millis_anteriores()=millis();
T=(millis_actuales-millis_anteriores)x1000

void setup (){
e=0,5
v=e/T
if (v > 50);
“open red led function”
else
“open green led function”

¿whats wrong?

And yes, im a real fucking n00b haha :stuck_out_tongue:

Thanks.

unsigned long millis_actuales();
unsigned long millis_anteriores();

These two lines declare functions, not variables.

millis_anteriores()=millis();

You can't assign a value (returned by millis()) to a function call.

Why are you not bothering to try to compile this stuff before posting?

Jorge_w202: void setup (){ e=0,5 v=e/T if (v > 50); "open red led function" else "open green led function"

¿whats wrong?

It's not C, that's what's wrong.

Statements should end with semicolons.

The decimal place is a period.

This is wrong (the only place you put a semicolon, it shouldn't be there):

if (v > 50);

This is misspelt:

insigned long T;                                          // (the time)

You need to take a bit of care with your spelling and syntax.

Get and read a book about C. This is fundamental stuff.