Pages: [1]   Go Down
Author Topic: Cycling through some motors  (Read 290 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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);
  }
}
Logged

Bristol, UK
Offline Offline
Edison Member
*
Karma: 0
Posts: 1197
Exhibitor at UK Maker Faire
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: [1]   Go Up
Jump to: