Lamp doesnt turn on

im trying to make a traffic light . but the red lamp doesnt turn on . im giving it the right voltage and i put the anode and the cathode on the right place but doesnt turn on
heres the code

/*
 * the soundy traffic light project
 * 1. how to use the play func
 * GREEN=10
 * YELLOW=9
 * RED=8
*/

int tones[10]={25,50,75,100,125,150,175,200,225,250};
int colorPin[3]={10,9,6};
void setup() {
  // put your setup code here, to run once:
  pinMode(11,OUTPUT);
}

void loop() {
  reset();
  light(1);
  play(5);
  delay(1000*45);
  reset();
  light(2);
  delay(1000*5);
  reset();
  light(3);
  play(5);
  delay(1000*45);
  
  
}

void play(int tone){

  analogWrite(11,tones[tone]);
  delay(300*3);
  digitalWrite(11,LOW);
  
  }

void light(int color){
  
  delay(100);
  digitalWrite(colorPin[color-1],HIGH);
  
  }
void reset(){
  digitalWrite(10,LOW);
  digitalWrite(9,LOW);
  digitalWrite(8,LOW);
  }

pls answer

Where is that supposed to happen?

void loop() {
reset();
light(1);

light and resets are voids i made

the red led burned :expressionless:

Did you forget a pinMode (or three)?
Comments would help.

Yep you need to set the pins that you connect the leds to as outputs using “ pinMode”

Use comments in your code and do one step
At a time - turn the leds on , then turn them off and move on !

Hi
missing pinMode() for pins 8 ,9 e 10.

sketch.ino - Wokwi Arduino and ESP32 Simulator example for a intersection signal. simple ones
https://create.arduino.cc/projecthub/techno_z/arduino-traffic-light-simulator-2ec9f7

oh late, my led burned

Did you forget the series current-limiting resistor?

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