ultrasonic sensor.

hello, i’m new to programming and i need to do a simple project, i have doubts if i can use auxiliary variables in arduino and how i can read and write in these variables.

my project consists of an ultrasonic sensor in which it measures the distance, if it is less than 70 centimeters it triggers the output 10 for 1 s, and when the object leaves the front, that is, when the distance is greater than 70 cm it triggers the output 9 , for 1s.

copy_of_manual_maker_alarme_de_dist_ncia1.ino (2.01 KB)

What do You mean by "auxiliary variables"?
Please supply code using code tags. I don't want to fill my Pc with stuff from members. That's explained in the beginning topics like "How to use forum", "How to attache code".

C assignment operator is =, not :=

void loop()
{
  int aux;
 
 
hcsr04(); // FAZ A CHAMADA DO MÉTODO "hcsr04()"
 
if(distancia <= 70){// SE A DISTÂNCIA ENTRE O OBJETO E O SENSOR ULTRASONICO FOR MENOR QUE 70CM, FAZ
delay(3000);
digitalWrite(10, LOW);;//ACIONA O RELE DE AVANÇO
delay(200);
digitalWrite(10, HIGH);
aux:=0;       //////////////////// BAD SYNTAX,  you meant "  aux = 0;"  <<<<<<<<<<<<<<<<<<<<
delay(5000);
}

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom... :slight_smile: