Total absolute noob from Chicago.

Hey all, Just received my Arduino a couple of days ago. I decided to switch from the PIC to the Arduino due to more users/projects being shared on the internet.
But anyway this programming using C/C++ language is way more complicated (to me) than simple BASIC.

Iv'e done a couple tutorials with blinking, potentiometer speed adjust, and a couple others.

I'm really into LEDs so right now i'm just focused on making more than say, one LED blink or maybe make all 13 LEDs blink at a speed directed by the potentiometer, or heck make the speed of the LEDs scan faster or slower using a potentiometer.

I've messed around with a couple different codes to initialize all 13 leds int ledPins[] = { 1,2,3,4,5,6,7,8,9,10,11,12,13};
then try

void setup() {                
  // initialize the digital pin as an output:
  pinMode(ledPins, OUTPUT);     
}

And from there i'm lost.. :o :-/

Ah you actuall have to put your set mode in a loop to set all of the pins.
Like this:
for (int pin=0; pin<10; pin++)
{
pinMode(pin, OUTPUT);
}

Get your self some books. I can recommend 30 Arduino Projects for the Evil Genius.

But I am biased! :wink:

You can also look at this example:

That code example allows you to also speed up or slow down the blinking with a 'timer' variable. You would want to change the timer variable based on turning the potentiometer. You can make your timer variable equal to the potentiometer values.

Ok, so i've got that down, I think.
But what do I have to do if I want all LEDs to go on when high and off when low?

It's gotta have something to do with this, right?
for (int pin=0; pin<13; pin++)

By 'high and low' you mean using a button or using a potentiometer?

You could do something like
if (the buttonState is HIGH or the potentiometer is high){
digitalWrite(1, HIGH);
digitalWrite(2, HIGH);
etc.
}

if(you want them off){ //something like (potentiometerValue<500)
digitalWrite(1,LOW);
digitalWrite(2,LOW);
etc.
}
That 'for' thing is called a 'for loop', look it up on google for an official explanation.

Hey, that helps too! I found out how to make all of the LEDs blink together.

But I was wondering if there was a simpler way to writing this following code. Like when I was doing BASIC there would be a code for all 8 LEDs (b10011011, the LEDs with 1's would be on and the LEDs with 0's would be off)
OR
like

digitalWrite ([1,2,3,4,5,6,7,8,9,10...], HIGH);
delay(300);
digitalwrite ([1,2,3,4,5,6,7,8,9,10...],LOW);
delay(300)

Please let me know if I'm totally going in the wrong direction. And thanks for bearing with me. :slight_smile:

void setup() {                
  
  
    pinMode(1, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(2, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(3, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(4, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(5, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(6, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(7, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(8, OUTPUT);   // initialize the digital pin(s) as an output:
    pinMode(9, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(10, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(11, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(12, OUTPUT); // initialize the digital pin(s) as an output:
    pinMode(13, OUTPUT); // initialize the digital pin(s) as an output:
    
    
}
void loop() {
  

  digitalWrite(1, HIGH);   // set the LED on
  digitalWrite(2, HIGH);   // set the LED on
  digitalWrite(3, HIGH);   // set the LED on
  digitalWrite(4, HIGH);   // set the LED on
  digitalWrite(5, HIGH);   // set the LED on
  digitalWrite(6, HIGH);   // set the LED on
  digitalWrite(7, HIGH);   // set the LED on
  digitalWrite(8, HIGH);   // set the LED on
  digitalWrite(9, HIGH);   // set the LED on
  digitalWrite(10, HIGH);   // set the LED on
  digitalWrite(11, HIGH);   // set the LED on
  digitalWrite(12, HIGH);   // set the LED on
  digitalWrite(13, HIGH);   // set the LED on
  
  
  delay(100);              // wait for a second
  
  digitalWrite(1, LOW);    // set the LED off
  digitalWrite(2, LOW);    // set the LED off
  digitalWrite(3, LOW);    // set the LED off
  digitalWrite(4, LOW);    // set the LED off
  digitalWrite(5, LOW);    // set the LED off
  digitalWrite(6, LOW);    // set the LED off
  digitalWrite(7, LOW);    // set the LED off
  digitalWrite(8, LOW);    // set the LED off
  digitalWrite(9, LOW);    // set the LED off
  digitalWrite(10, LOW);    // set the LED off
  digitalWrite(11, LOW);    // set the LED off
  digitalWrite(12, LOW);    // set the LED off
  digitalWrite(13, LOW);    // set the LED off
  
  delay(100);              // wait for a second
}

You can't list them in a row as far as I know, but you can use a for loop.
for (i=1;i<14;i++){
digitalWrite(i, HIGH);
}
it starts at 1, adds one every time ++ and keeps looping until it violates the middle parameter.