Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15346

Problem with Arduino nano analog pins

$
0
0

for an issue there are 6 leds needed tobe switched on/off via analog pins !
i guessed that would be really simple :grinning:

but 2 off the 6 leds are Not enlightened !
that are on A6 and A7 (A4,A5 are used for I2C)
have checked all leds electrically on connections and lighting, all ok !
whats wrong with the code ?

/*
  check leds
*/
  
#define TRAFFIC_LIGHT_SPEED 500

const int led_pins_list[6] = {A0,A1,A2,A3,A6,A7};
// the setup function runs once when you press reset or power the board
void setup()
{
  Serial.begin(9600);
  // initialize digital pin LED_BUILTIN as an output.
  for(int i = 0;i < 6;i++)
  {
    pinMode(led_pins_list[i], OUTPUT);
  }
}

// the loop function runs over and over again forever
void loop()
{
  for(int i = 0;i < 6;i++)
  {
    analogWrite(led_pins_list[i], 255);   // turn the LED on (HIGH is the voltage level)
    delay(TRAFFIC_LIGHT_SPEED);                       // wait for a second
    analogWrite(led_pins_list[i], 0);    // turn the LED off by making the voltage LOW
    delay(TRAFFIC_LIGHT_SPEED);                       // wait for a second    
  }
}

any idea ?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 15346

Trending Articles