help for a circuit

can you tell me help to build a cicuit to do it?...i can't understend where i have to put the BUZZ_PIN...the code was that and is for an alarm:

#define TRIG_PIN 10
#define ECHO_PIN 9
#define BUZZ_PIN 8

void setup() {
  Serial.begin(9600);
  pinMode(TRIG_PIN, OUTPUT);
  pinMode(ECHO_PIN, INPUT);
  digitalWrite(TRIG_PIN, LOW);
}

void loop() {
  digitalWrite(TRIG_PIN, HIGH);
  delayMicroseconds(20);
  digitalWrite(TRIG_PIN, LOW);

  unsigned long tempo = pulseIn(ECHO_PIN, HIGH);
  float distanza = 0.03438 * tempo / 2;

  Serial.print("distanza: ");
  Serial.print(distanza);
  Serial.println("cm");
  delay(20);
 
  if(distanza <= 40)
  {
    digitalWrite(BUZZ_PIN, HIGH);
  }
  else
  {
    digitalWrite(BUZZ_PIN, LOW);
  }
 }

Read line 3 of your code, then read the arduino docs. Or vice versa.

were i can found arduino docs please?

ardino.cc would be a starting place.

Hi,
I think one thread at a time on the same subject would be easier to get assistance?

https://forum.arduino.cc/index.php?topic=628313.0

Tom... :slight_smile:

Hi,
try here;

and

Tom.. :slight_smile: