Go Down

Topic: Arduino Uno, pins 0-3 are constantly on (Read 1 time) previous topic - next topic

GiverOfCake

May 30, 2012, 04:20 am Last Edit: May 30, 2012, 05:02 am by GiverOfCake Reason: 1
Beginner to Arduino here, just bought my board (Uno) yesterday, and it worked fine for a while. I was able to control a stepper motor with it before it crashed. Currently, my board cannot store my code, although I haven't gotten any error messages from my IDE or my computer. Pins 0-3 are always on, and pins 4-13 are always off, regardless of what my program says. I'm not sure if it can't store anything, or if it's still running the last program I put onto it, which was a simple stepper motor controller using pins 0-3 (which worked perfectly a few hours ago).

The stepper motor controller was a simple circuit that used a ULN2003A transistor array to control a 5-wire stepper motor (PM55L-048, unsure if bi- or unipolar). It worked fine. Then I attempted to control a 4-wire stepper (Sanyo B00324, probably bipolar), both with and without the transistor array (connected directly to the arduino). I played around the wiring, since I was unsure of the configuration. The motor never spun, but kept vibrating. After about an hour of tinkering, I gave up, and went back to playing with the 5-wire stepper. My circuit/code setup no longer worked, and the pins are now stuck in the state described above. I have tried and failed to reprogram the pins.

I will gladly provide any additional details. Any help is appreciated.


EDIT: Should probably include my circuit as well. I followed this one, but didn't use the pot:
http://static.flickr.com/32/54357295_756c131217_o.jpg

cmiyc


I will gladly provide any additional details. Any help is appreciated.

Let's start with your code.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

GiverOfCake

My bad, shoulda included it in the original post.

This is the code for the 5-wire stepper. I had no problem operating it:
Code: [Select]
char motorPin[]={0,1,2,3};

void setup()
{
for(int i=0;i<4;i++)
pinMode(motorPin [i],OUTPUT);
}

void loop()
{
  ccwTurn();
}

void cwTurn()
{
  motor4();
  delay(10);
  motor3();
  delay(10);
  motor2();
  delay(10);
  motor1();
  delay(10);
}

void ccwTurn()
{
  motor1();
  delay(10);
  motor2();
  delay(10);
  motor3();
  delay(10);
  motor4();
  delay(10);
}

void motor1()
{
digitalWrite(motorPin [0],HIGH);
digitalWrite(motorPin [1],LOW);
digitalWrite(motorPin [2],LOW);
digitalWrite(motorPin [3],LOW);
}
void motor2()
{
digitalWrite(motorPin [0],LOW);
digitalWrite(motorPin [1],HIGH);
digitalWrite(motorPin [2],LOW);
digitalWrite(motorPin [3],LOW);
}
void motor3()
{
digitalWrite(motorPin [0],LOW);
digitalWrite(motorPin [1],LOW);
digitalWrite(motorPin [2],HIGH);
digitalWrite(motorPin [3],LOW);
}
void motor4()
{
digitalWrite(motorPin [0],LOW);
digitalWrite(motorPin [1],LOW);
digitalWrite(motorPin [2],LOW);
digitalWrite(motorPin [3],HIGH);
}



As for the 4-wire motor, I initially tried it with the above code, but it failed, so I tried the following (which obviously didn't work):
Code: [Select]
char motorPin[]={0,1,2,3};

void setup()
{
for(int i=0;i<4;i++)
pinMode(motorPin [i],OUTPUT);
}

void loop()
{
  motor1();
  delay(10);
  motor2();
  delay(10);
}

void motor1()
{
digitalWrite(motorPin [0],HIGH);
digitalWrite(motorPin [1],LOW);
digitalWrite(motorPin [2],HIGH);
digitalWrite(motorPin [3],LOW);
}
void motor2()
{
digitalWrite(motorPin [0],LOW);
digitalWrite(motorPin [1],HIGH);
digitalWrite(motorPin [2],LOW);
digitalWrite(motorPin [3],HIGH);
}

Go Up