hello i need help code. ive posted video of my wardware. and my very simple code

its a combination of a

for, and switch statement. controlling a led matrix.

im trying to control these light with a homemade button pad with each button connected with different resisters to control certain sequence.

and potentiameter to control the delay.

im trying to make a synchronized music video with the lights. thanks!

Alice

int colPin1 = 5;
int colPin2 = 6;
int colPin3 = 7;
int colPin4 = 8;
int colPin5 = 9;
int colPin6 = 10;
int colPin7 = 11;
int colPin8 = 12;

int rowPin1 = A1;
int rowPin2 = A2;
int rowPin3 = A3;
int timeDelay = 1;

void setup() {
pinMode(colPin1, OUTPUT);
pinMode(colPin2, OUTPUT);
pinMode(colPin3, OUTPUT);
pinMode(colPin4, OUTPUT);
pinMode(colPin5, OUTPUT);
pinMode(colPin6, OUTPUT);
pinMode(colPin7, OUTPUT);
pinMode(colPin8, OUTPUT);
pinMode(rowPin1, OUTPUT);
pinMode(rowPin2, OUTPUT);
pinMode(rowPin3, OUTPUT);

}

void loop()
{
  digitalWrite(colPin1,LOW);
digitalWrite(colPin2, HIGH);
digitalWrite(colPin3, HIGH);
digitalWrite(colPin4, HIGH);
digitalWrite(colPin5, HIGH);
digitalWrite(colPin6, HIGH);
digitalWrite(colPin7, HIGH);
digitalWrite(colPin8, HIGH);

digitalWrite(rowPin1, HIGH);
digitalWrite(rowPin2, HIGH);
digitalWrite(rowPin3, HIGH);

delay(timeDelay);
digitalWrite(colPin1,HIGH);
digitalWrite(colPin2, LOW);
digitalWrite(colPin3, HIGH);
digitalWrite(colPin4, HIGH);
digitalWrite(colPin5, HIGH);
digitalWrite(colPin6, HIGH);
digitalWrite(colPin7, HIGH);
digitalWrite(colPin8, HIGH);

digitalWrite(rowPin1, HIGH);
digitalWrite(rowPin2, HIGH);
digitalWrite(rowPin3, HIGH);

delay(timeDelay);

i am trying to incorporate for() statement with switch() statement.

i am high school drop out. so someof the stuff it is very difficult to understand.

the tutorials and references are so vague.

tigerspittingfire:
i am trying to incorporate for() statement with switch() statement.

In what way?

ok.

everytime i push a button with a specific resistance i want it to trigger a different sequence.

so one button will make the lights basically go clock wise.

and if i press a different button the lights will go the reverse way.

and anoter button to randomly select each combination.

whats the most confusing to me is that this is an matrix.

its like combining

void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pins:
  for (int thisPin = 2; thisPin < 7; thisPin++) {
    pinMode(thisPin, OUTPUT);
  }
}

void loop() {
  // read the sensor:
  if (Serial.available() > 0) {
    int inByte = Serial.read();
    // do something different depending on the character received.
    // The switch statement expects single number values for each case;
    // in this exmaple, though, you're using single quotes to tell
    // the controller to get the ASCII value for the character.  For
    // example 'a' = 97, 'b' = 98, and so forth:

    switch (inByte) {
      case 'a':
        digitalWrite(2, HIGH);
        break;
      case 'b':
        digitalWrite(3, HIGH);
        break;
      case 'c':
        digitalWrite(4, HIGH);
        break;
      case 'd':
        digitalWrite(5, HIGH);
        break;
      case 'e':
        digitalWrite(6, HIGH);
        break;
      default:
        // turn all the LEDs off:
        for (int thisPin = 2; thisPin < 7; thisPin++) {
          digitalWrite(thisPin, LOW);
        }
    }
  }
}

with

/*
  For Loop Iteration

 Demonstrates the use of a for() loop.
 Lights multiple LEDs in sequence, then in reverse.

 The circuit:
 * LEDs from pins 2 through 7 to ground

 created 2006
 by David A. Mellis
 modified 30 Aug 2011
 by Tom Igoe

This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/ForLoop
 */

int timer = 100;           // The higher the number, the slower the timing.

void setup() {
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 2; thisPin < 8; thisPin++) {
    pinMode(thisPin, OUTPUT);
  }
}

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 2; thisPin < 8; thisPin++) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(thisPin, LOW);
  }

  // loop from the highest pin to the lowest:
  for (int thisPin = 7; thisPin >= 2; thisPin--) {
    // turn the pin on:
    digitalWrite(thisPin, HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(thisPin, LOW);
  }
}

and

/*
  Button

 Turns on and off a light emitting diode(LED) connected to digital
 pin 13, when pressing a pushbutton attached to pin 2.


 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached to pin 2 from +5V
 * 10K resistor attached to pin 2 from ground

 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.


 created 2005
 by DojoDave <http://www.0j0.org>
 modified 30 Aug 2011
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/Button
 */

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

i understand the concept and how it works individually. but when i try to combine it peice together what i need. i just dont understand.

what i want is pretty simple.

its similar to the led matrix cube things you can buy. just assembled differently

You need to read this Demonstration code for several things at the same time - Project Guidance - Arduino Forum

You MUST NEVER USE DELAY.

Tom Igoe's examples show that you need to do to the pins in order to get a particular effect. They do not show how to write code. They are not intended to show you how to program.

Mark

thank you! any educational information helps!

this is my first forum. so please excuse my newby ness.

thank you for your helps.