Help! Code won't delete from my Arduino

Hi, I was assigned two Arduino projects. The first one worked fine, but now that I need to do the second one, it’s not working. However, I’ve noticed that the first project is still functioning, meaning my Arduino still “thinks” I’m using the first one. PLEASE HELP!

Im also uploading what im seeing in my serial monitor

And the last code

#include <Servo.h>

Servo miServo;  // Crear objeto servo

const int pinPIR = 7;
const int pinServo = 9;
const int pinBuzzer = 5;

bool movimientoDetectado = false;

void setup() {
pinMode(pinPIR, INPUT);
pinMode(pinBuzzer, OUTPUT);
miServo.attach(pinServo);

// Posición INICIAL: Boca ABIERTA
miServo.write(0);
noTone(pinBuzzer);

Serial.begin(9600);
Serial.println(“🤖 Robot Mordedor ACTIVADO - Esperando movimiento…”);
}

void loop() {
int valorPIR = digitalRead(pinPIR);

// Si detecta movimiento y no estaba detectado
if (valorPIR == HIGH && !movimientoDetectado) {
Serial.println(“🎯 ¡MANO DETECTADA! - ¡MORDIENDO!”);
movimientoDetectado = true;


// 1. CERRAR BOCA (Morder)
miServo.write(90);
// 2. SONIDO DE MORDIDA
tone(pinBuzzer, 150, 500); // Sonido grave por 500ms

delay(1500); // Tiempo con la boca cerrada (1.5 segundos)

// 3. ABRIR BOCA (Soltar)
miServo.write(0);
Serial.println("✅ Boca abierta - Listo para siguiente víctima");

delay(1000); // Pequeña pausa después de abrir


}

// Resetear cuando ya no hay movimiento
if (valorPIR == LOW) {
movimientoDetectado = false;
}

delay(100);
}

and the new code i need to put but it doesnt work

#include <Servo.h>

Servo servo;
const int trigPin = 9;
const int echoPin = 10;
long duration;
int distance;
void setup() {
  servo.attach(6);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  servo.write(0);
  Serial.begin(9600);
}

void loop() {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration\ * 0.034 / 2;
  Serial.print(“Distancia: “);
  Serial.print(distance);
  Serial.println(”cm”);
  if (distance < 10) {
    for (int pos = 90; pos >= 0; pos–) {
      servo.write(pos);
      delay(15);
    }
    delay(3000);
    for (int pos = 0; pos <= 90; pos++) {
      servo.write(pos);
      delay(15);
    }
    delay(100);
  }
  delay(100);
}

it is like my arduino it stuck in the old code because i literally try everything but nothing work

PLEASE HELP

So, are there any errors when you press the “Upload” button? Can you provide a screenshot of the IDE after you pressed the upload button, with the file explorer sidebar open?

Hello max thanks for responding my message there are any errors is like is working normally but with the old code, its like the old code is stucked in the arduino, I dont show any captures because its literally the new sketch and thats it

to resume no errors, only my old code

The above line in your `loop()` looks wrong. The ‘\’ character specifically.

This means your code did not compile, so there was nothing to upload, so the Arduino keeps running whatever was previously uploaded.

HTH

Cheers,

Norm.