'const int delay' redeclared as different kind of symbol

i've been trying to figure out what's wrong with it and I can't wrap my head around there, any guidance would be much appreciated! I'm pretty much a noob when it comes to coding. i tried to do an ultrasound sensor that changes the led rgb light once you get close, Here's the code.

//comments in Spanish

#include <Adafruit_NeoPixel.h>

const int EchoPin = 5;
const int TriggerPin = 6;
const int dist[] = {100, 200, 300};
const String colors[] = {"blau", "vermell", "verd"};
const int delay = 3000;

int PIN=6; //Pin donde está conectada la tira de leds
int NUMPIXELS=30; //Número de leds conectados

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
Serial.begin(9600);
pinMode(TriggerPin, OUTPUT);
pinMode(EchoPin, INPUT);
}
void loop() {
int cm = ping(TriggerPin, EchoPin);
Serial.print("Distancia: ");
Serial.println(cm);
startSequence (cm)
delay(1000);
}
int ping(int TriggerPin, int EchoPin) {
long duration, distanceCm;
sendPing

duration = pulseIn(EchoPin, HIGH);  //medir temps ms

distanceCm = duration * 10 / (292 * 2); //calcular a cm
return distanceCm;
}
void sendPing () {

digitalWrite(TriggerPin, LOW); //generar puls
delayMicroseconds(4);
digitalWrite(TriggerPin, HIGH); //Trigger
delayMicroseconds(10);
digitalWrite(TriggerPin, LOW);
}

void startSequence (int cm) {

String color;

Switch (cm) {
case dist [0]:
color = colors [0];
break;

case dist [1]:
  color = colors [1];
  break;

case dist [2]:
  color = colors [2];
  break;  

}
switchOnLights (color);

}

void switchOnLights (String color) {

// encendre leds (buscar llibreria - demanar joan)

delay (delay)

// apagar leds

}

void setup() {
pixels.begin(); // Inicialización
pixels.show(); // Inicialitza tots els pixels apagats
}

void loop() {
pixels.setPixelColor(0,0,0,255);
pixels.show();
delay (1000);
pixels.setPixelColor(0,0,0,0);
pixels.show();

pixels.setPixelColor(1,0,0,255);
pixels.show();
delay (1000);
pixels.setPixelColor(1,0,0,0);
pixels.show();

pixels.setPixelColor(2,0,0,255);
pixels.show();
delay (1000);
pixels.setPixelColor(2,0,0,0);
pixels.show();

}

'delay' is the name of a predefined Arduino function. You can't use it to name a variable. Call your variable something else.

Do you see any problems with that line? If not, check the compiler error messages. There will be several.

Please use code tags when posting code.

That should read

switch (cm) {

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