Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumProgramming Questions & HelpSyntax › Leds in sequence then in reverse

Page Index Toggle Pages: 1
Leds in sequence then in reverse (Read 3652 times)
03/18/08 at 21:44:17

sidgug   Offline
YaBB Newbies
I Love YaBB 2!
Brisbane, Australia

Posts: 10
*
 
I've had this program working well in the Arduino environment. I'm now trying to port it over to the Wiring environment but can't get it to compile.

I'm assuming parts of the code need to modified but can't work out which parts.

Can someone please look at the code and suggest what mods are required?

Thanks in advance.


int timer = 10;                                          
int pins[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 }; // an array of pin numbers
int num_pins = 12;                                       // length of the array

void setup()
{
  int i;

  for (i = 0; i < num_pins; i++)          // the array elements from 0 to num_pins - 1
    pinMode(pins[i], OUTPUT);             // set each pin as an output
}

void loop() {
  int i;
 
  for (i = 0; i < num_pins; i++) {        // loop through each pin...
    digitalWrite(pins[i], HIGH);          // turning pin on,
    delay(timer);                         // wait,
    digitalWrite(pins[i], LOW);           // turning pin off.
  }
  for (i = num_pins - 1; i >= 0; i--) {   // now in reverse
    digitalWrite(pins[i], HIGH);
    delay(timer);
    digitalWrite(pins[i], LOW);
  }
}
 
IP Logged
 
Reply #1 - 03/19/08 at 00:21:36

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
"pins" is reserved in Wiring, change your array name to something else, like "myPins".
That´s it.
 
IP Logged
 
Reply #2 - 03/19/08 at 01:37:56

sidgug   Offline
YaBB Newbies
I Love YaBB 2!
Brisbane, Australia

Posts: 10
*
 
Thanks Hernando.

Now compiles and works perfectly!
 
IP Logged
 
Page Index Toggle Pages: 1