Pages: [1]   Go Down
Author Topic: Knight rider  (Read 486 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
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?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 653
Posts: 50881
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
    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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 29
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 72
Posts: 3761
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: