Go Down

Topic: Cycling through some motors (Read 398 times) previous topic - next topic

Interesting

Anyone see anything wrong with this code? I am trying to rotate setting some motors to high/low as a test, but sometimes 3 come on, and it misses other ones. I don't see what could be wrong with this, but I just want to make sure before I go to the lab tomorrow.

When I tried some other code that shifted through the motors with names for the motors (m1) it would work individually on all of them except for skipping some.


Code: [Select]
void setup ()
{
pinMode(0, OUTPUT);
digitalWrite(0, LOW);
pinMode(1, OUTPUT);
digitalWrite(1, LOW);
pinMode(2, OUTPUT);
digitalWrite(2, LOW);
pinMode(3, OUTPUT);
digitalWrite(3, LOW);
pinMode(4, OUTPUT);
digitalWrite(4, LOW);
pinMode(5, OUTPUT);
digitalWrite(5, LOW);

}
void loop ()
{
 for(int i = 0; i < 5; i++)
 {
   digitalWrite(i, HIGH);
   delay(1000);
   digitalWrite(i, LOW);
 }
}


Anachrocomputer

Beware that digital pins 0 and 1 are also used for serial I/O to the host (via the FTDI chip).  But since you're not using Serial.print(), that shouldn't matter.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy