Go Down

Topic: Arduino UNO+Motor Shield DC motor controlling ! (Read 3693 times) previous topic - next topic

shadowcand

Hello,

I have an Arduino UNO R3 and Motor Shield. I want to control a dc motor via motor shield.

I am new at programming.

Are there any control program example  for me ? Thank you.

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

shadowcand

I found this code for using one DC motor but the motor did not work. I got this error : avrdude: stk500_getsync(): not in sync: resp=0x00

How can I fix this code ?

Code: [Select]
void setup() {
 
 //Setup Channel A
 pinMode(12, OUTPUT); //Initiates Motor Channel A pin
 pinMode(9, OUTPUT); //Initiates Brake Channel A pin
 
}

void loop(){
 
 //forward @ full speed
 digitalWrite(12, HIGH); //Establishes forward direction of Channel A
 digitalWrite(9, LOW);   //Disengage the Brake for Channel A
 analogWrite(3, 128);   //Spins the motor on Channel A at full speed
 
 delay(3000);
 
 digitalWrite(9, HIGH); //Eengage the Brake for Channel A

 delay(1000);
 
 //backward @ half speed
 digitalWrite(12, LOW); //Establishes backward direction of Channel A
 digitalWrite(9, LOW);   //Disengage the Brake for Channel A
 analogWrite(3, 123);   //Spins the motor on Channel A at half speed
 
 delay(3000);
 
 digitalWrite(9, HIGH); //Eengage the Brake for Channel A
 
 delay(1000);

 

AWOL

#3
Oct 08, 2012, 01:35 pm Last Edit: Oct 08, 2012, 01:43 pm by AWOL Reason: 1
There's nothing wrong with the code (well, nothing syntactically wrong) - that's an upload error; did you select and connect the correct board?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

PaulS

Quote
did you select and connect the correct board?

And, did you make sure that there is nothing connected to pins 0 and 1 (directly or via any shield)?

shadowcand

Yes, I selected the correct board (Arduino UNO R3).

shadowcand


Quote
did you select and connect the correct board?

And, did you make sure that there is nothing connected to pins 0 and 1 (directly or via any shield)?


There is nothing connected any pins on shield. Just USB and motor connections on shield (A+ A-) are connected


PaulS

Quote
Is there any idea ?

I have a couple. First, you might try telling us, via a link, just which shield you have.

Second, you might try removing the shield while uploading the sketch.

Go Up