Go Down

Topic: i need help with motor drive (Read 116 times) previous topic - next topic

amirgaziel0

hi

I connect the ports of engines Motor Drive
They work non-stop all out
I do not know what my mistake
It Https://cdn-shop.adafruit.com/1200x900/81-02. Gfg

// Adafruit Motor shield library
// Copyright Adafruit Industries LLC, 2009
// This code is public domain, enjoy!

#include <AFMotor.h>
#include <Servo.h>

// DC motor on M2
AF_DCMotor motor (1);
// DC servo Hobby
Servo Servo1;
// Stepper motor on the M3 + M4 48 steps per revolution
AF_Stepper stepper (48, 2);

void setup () {
  Serial.begin (9600); // Set up the Serial library at 9600 bps
  Serial.println ( "Motor party!");
  
  // Turn on servo
  Servo1.attach (9);
   
  // Turn on motor # 2
  motor.setSpeed ​​(200);
  motor.run (RELEASE);
}

int i;

Test the DC // motor, stepper and servo ALL AT ONCE!
void loop () {
  motor.run (FORWARD);
  for (i = 0; i <255; i ++) {
    Servo1.write (i);
    Motor.setSpeed ​​(i);
    stepper.step (1, FORWARD, INTERLEAVE);
    delay (3);
 }
 
  for (i = 255; i! = 0; i--) {
    servo1.write (i-255);
    Motor.setSpeed ​​(i);
    stepper.step (1, BACKWARD, INTERLEAVE);
    delay (3);
 }
 
  motor.run (BACKWARD);
  for (i = 0; i <255; i ++) {
    Servo1.write (i);
    Motor.setSpeed ​​(i);
    delay (3);
    stepper.step (1, FORWARD, DOUBLE);
 }
 
  for (i = 255; i! = 0; i--) {
    servo1.write (i-255);
    Motor.setSpeed ​​(i);
    stepper.step (1, BACKWARD, DOUBLE);
    delay (3);
 }
}

amirgaziel0

this is the motor

Robin2

It is much easier for us if you use use the code button </> so your code looks like this and is easy to copy to a text editor.
Code: [Select]
// Adafruit Motor shield library
// Copyright Adafruit Industries LLC, 2009
// This code is public domain, enjoy!

#include <AFMotor.h>
#include <Servo.h>

// DC motor on M2
AF_DCMotor motor (1);
// DC servo Hobby
Servo Servo1;
// Stepper motor on the M3 + M4 48 steps per revolution
AF_Stepper stepper (48, 2);

void setup () {
  Serial.begin (9600); // Set up the Serial library at 9600 bps
  Serial.println ( "Motor party!");
 
  // Turn on servo
  Servo1.attach (9);
   
  // Turn on motor # 2
  motor.setSpeed ​​(200);
  motor.run (RELEASE);
}

int i;

Test the DC // motor, stepper and servo ALL AT ONCE!
void loop () {
  motor.run (FORWARD);
  for (i = 0; i <255; i ++) {
    Servo1.write (i);
    Motor.setSpeed ​​(i);
    stepper.step (1, FORWARD, INTERLEAVE);
    delay (3);
 }
 
  for (i = 255; i! = 0; i--) {
    servo1.write (i-255);
    Motor.setSpeed ​​(i);
    stepper.step (1, BACKWARD, INTERLEAVE);
    delay (3);
 }
 
  motor.run (BACKWARD);
  for (i = 0; i <255; i ++) {
    Servo1.write (i);
    Motor.setSpeed ​​(i);
    delay (3);
    stepper.step (1, FORWARD, DOUBLE);
 }
 
  for (i = 255; i! = 0; i--) {
    servo1.write (i-255);
    Motor.setSpeed ​​(i);
    stepper.step (1, BACKWARD, DOUBLE);
    delay (3);
 }
}


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

The first thing to do is to write a series of short programs to get each motor to work on its own.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

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