Go Down

Topic: Help! Trying to modify Sketch (Read 1 time) previous topic - next topic

iyahdub

you right. i wrote that quick example on the move anyway.
10 LET Loop=Infinite
20 GO TO 10

iyahdub

10 LET Loop=Infinite
20 GO TO 10

iyahdub

Something wrong in your code but cant see what it is, tbh
10 LET Loop=Infinite
20 GO TO 10

robtillaart


I can, I missed the () after millis(), I fixed it in the code above.

please retry.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

iyahdub

Corrected, though im not sure this is what you wanted. Still, its an example of how to implement it. Hope it helps to get the logic of it, so u can implement it to suit you.
Code: [Select]
int ledPins[] = {
 2, 5, 9, 13 };       // an array of pin numbers to which LEDs are attached
int pinCount = 4;           // the number of pins (i.e. the length of the array)
// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated
// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;      

void setup() {
 // initialize serial communication at 9600 bits per second:
 Serial.begin(9600);
 // make the pushbutton's pin an input:
}


void loop() {
 // loop from the lowest pin to the highest:
 // check to see if it's time to blink the LED; that is, if the
 // difference between the current time and last time you blinked
 // the LED is bigger than the interval at which you want to
 // blink the LED.
 unsigned long currentMillis = millis();
 if(currentMillis - previousMillis > interval) {
   // save the last time you blinked the LED
   previousMillis = currentMillis;  
   // if the LED is off turn it on and vice-versa:
   if (ledState == LOW)
     ledState = HIGH;
   else
     ledState = LOW;
 }
 int thisPin;
 // 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);  
   digitalWrite(ledPins[thisPin], ledState);
   Serial.println(ledState);  
 }
}




10 LET Loop=Infinite
20 GO TO 10

Go Up