multiple loops

at the moment i am trying to make an arduino control an lcd and an led array at the same time but my two sample peices of code are clashing here are the samples i started with (i removed the introductions and adjusted the pins to suit me)

int timer = 100;           // The higher the number, the slower the timing.
int ledPins[] = {
  1, 7, 0, 6, 8, 9, 10, 13 
};       // an array of pin numbers to which LEDs are attached
int pinCount = 8;           // the number of pins (i.e. the length of the array)

void setup() {
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    pinMode(ledPins[thisPin], OUTPUT);
  }
}

void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);

  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);
  }
}
// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void set() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}



int timer = 300;           // The higher the number, the slower the timing.
int ledPins[] = {
 7, 8, 9, 1, 0, 10, 13, 6, 
};       // an array of pin numbers to which LEDs are attached
int pinCount = 8;           // the number of pins (i.e. the length of the array)

void setup() {
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    pinMode(ledPins[thisPin], OUTPUT);
  }
}
void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);

  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], LOW);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], HIGH);
  }
}

and here is what i ended up with

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void set() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}



int timer = 300;           // The higher the number, the slower the timing.
int ledPins[] = {
 7, 8, 9, 1, 0, 10, 13, 6, 
};       // an array of pin numbers to which LEDs are attached
int pinCount = 8;           // the number of pins (i.e. the length of the array)

void setup() {
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    pinMode(ledPins[thisPin], OUTPUT);
  }
}
void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);

  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], LOW);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], HIGH);
  }
}

the two void-loop commands are clashing if anyone could fix this is would be very much appretiated

You can only have one setup() and one loop() in a sketch.

yes i know but is there any way i can get around it

First get rid of all the delay()'s. Then read this Demonstration code for several things at the same time - Project Guidance - Arduino Forum

Mark

i have read that webpage but i am very new to arduino and cant make nor heads or tails of it

Sounds like you need to some hands on programming.
Try writing a sketch to blink 3 LEDs.
One led flashes every second.
One led flashes every 1/10th second.
The last led turns on with a push of a button then off when the button is pushed again.

If you can manage this I am sure you will be able to do your project.
.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

[b]Drag mouse over this block of code 
[b][b][/b][/b][/b]
[b]start here[/b] 




//void set() {
//  // set up the LCD's number of columns and rows:
//  lcd.begin(16, 2);
//  // Print a message to the LCD.
//  lcd.print("hello, world!");
//}
//
//void loop() {
//  // set the cursor to column 0, line 1
//  // (note: line 1 is the second row, since counting begins with 0):
//  lcd.setCursor(0, 1);
//  // print the number of seconds since reset:
//  lcd.print(millis()/1000);
//}
//


[b]Drag mouse over this block of code 
[b][b][/b][/b][/b]
[b]end here[/b] 

[b]Than use EDIT Comment / Uncomment  to comment out the selected block and recompile. [/b]
Fix any compiler error and than we can discuss what to do next 





int timer = 300;           // The higher the number, the slower the timing.
int ledPins[] = {
 7, 8, 9, 1, 0, 10, 13, 6,
};       // an array of pin numbers to which LEDs are attached
int pinCount = 8;           // the number of pins (i.e. the length of the array)

void setup() {
  // the array elements are numbered from 0 to (pinCount - 1).
  // use a for loop to initialize each pin as an output:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    pinMode(ledPins[thisPin], OUTPUT);
  }
}
void loop() {
  // loop from the lowest pin to the highest:
  for (int thisPin = 0; thisPin < pinCount; thisPin++) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], HIGH);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], LOW);

  }

  // loop from the highest pin to the lowest:
  for (int thisPin = pinCount - 1; thisPin >= 0; thisPin--) {
    // turn the pin on:
    digitalWrite(ledPins[thisPin], LOW);
    delay(timer);
    // turn the pin off:
    digitalWrite(ledPins[thisPin], HIGH);
  }
}

jcdowen123:
i have read that webpage but i am very new to arduino and cant make nor heads or tails of it

It would be worth the time and trouble to try the example in several things at a time and study it until you understand it all. Most of the concepts in it will arise again and again in your Arduino programming.

See also planning and implementing a program

This simple merge demo may also be useful

...R

Please ignore the blocks of bold tags ([b][/b] ) in Vaclav's post - they'll only confuse you.