I need help with my code on Arduino Nano

ENGLISH:
Hello, my name is Lucas and I'm new to the world of programming via Arduino, I'm working on a project for glasses for the visually impaired and in this pair of glasses in its base programming I have to use an HC-SR04 ultrasonic sensor, along with a buzzer on an Arduino nano, the ultrasound sensor, when detecting an object at a distance of less than 1.5 meters (150 centimeters) will send a signal to the buzzer that will make a sound at a frequency of 523hz for 3 seconds. When checking the code, the Arduino IDE application showed that my code has an error:

In function 'void loop()':
22:3: error: 'delayMicrosecods' was not declared in this scope
22:3: note: suggested alternative: 'delayMicroseconds'
36:3: error: expected ';' before 'float'
39:20: error: 'a1' was not declared in this scope
39:20: note: suggested alternative: 'A1'

avre[0m 1.8.6 e[90m/home/tcad/.arduino15/packages/arduino/hardware/avr/1.8.6e[0m
exit status 1

I am unable to correct this error, can anyone help me please? Below I leave my current code.

#define trigPin1 3
#define echoPin1 4
#define buzzer 5

void setup() {
  pinMode (trigPin1, OUTPUT);
  pinMode (echoPin1, INPUT);

  pinMode (buzzer, OUTPUT);

  Serial.begin(9600); // inicializa biblioteca 
}

void loop() {
  // Serial.println ("Passagem na sequencia distancia1")
  float duration1, distance1;

  digitalWrite(trigPin1, LOW);
  delayMicroseconds(2); // delay de 2 microsegundos 

  digitalWrite (trigPin1, HIGH);
  delayMicrosecods(10); //delay de 10 microsegundos

  digitalWrite(trigPin1,LOW);
  duration1 = pulseIn(echoPin1, HIGH); //pulseIn Lê o tempo entre a chamada e o pino entrar até em sinal HIGH

  //esse calculo é baseado em s= v . t, lembrando que o tempo vem dobrado

  //porque é o tempo de ida e volta do ultrassom
  distance1= (duration1/2) / 29.1;

  delay(50)

  //fim de leitura distancia1

  float a1=distance1;
  //float tempo=(float) millis()/60000; //leitura do tempo
    // acompanhamento na saida serial para dados de distancia
    Serial.println(a1);



if(a1<150.){
  tone( buzzer, 523);

  delay(300);
  noTone(buzzer);

 //delay (500);
}
}

You misspelled delayMicroseconds as delayMicrosecods in line 22, and you forgot the semicolon after delay(50) in line 32.

1 Like

Obrigado mano, ajudou muito! Eu não tinha percebido esses pequenos detalhes.

Thanks for the tip and the solution, thank you very much!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.