Go Down

Topic: Knight rider (Read 565 times) previous topic - next topic

rawriano

Code: [Select]

const int lowestPin = 9;
const int highestPin = 13;


void setup() {
  // set pins 2 through 13 as outputs:
  for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++) {
    pinMode(thisPin, OUTPUT);
  }
}

void loop() {
  for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++){
    digitalWrite(thisPin, thisPin);
    delay(100);
  }
}

It just lights them up (of course not all of them in one time which is the thing i want) and they stay on so how do i make it repeat?

PaulS

Code: [Select]
    digitalWrite(thisPin, thisPin);
You need to look at the documentation for the digitalWrite() function, to see what the arguments are supposed to be. Only one is a pin NUMBER.

Quote
and they stay on

Because you don't turn them off.

Quote
so how do i make it repeat?

There must be about 800 million variations of this code floating around. I find it a bit difficult to believe that you can't find code that works.

rawriano


There must be about 800 million variations of this code floating around. I find it a bit difficult to believe that you can't find code that works.
[/quote]
Well you see i like to do it myself not copy paste from the internet

wildbill

Well luckily in this case, you can just copy and paste your own code. digitalWrite's second parameter should be HIGH or LOW. Fix that and then copy & paste your for loop so you have one version setting the leds HIGH followed by one that sets them LOW.

Go Up