Hi
I am using 2 DC motors on a motor shield with Arduino Uno.
Can someone please help me edit my code which is for a V2 shield to a V1 shield?
#include <Wire.h>
#include <AFMotor.h> //Include library AF Motor
#define SPEED 100
#define TIMEUP 1000
#define TIMEDOWN 1000
static Adafruit_MotorShield motors = Adafruit_MotorShield();
static Adafruit_DCMotor * pager1 = motors.getMotor(1);
static Adafruit_DCMotor * pager2 = motors.getMotor(2);
void
setup()
{
motors.begin();
pager1->setSpeed(SPEED);
pager2->setSpeed(SPEED);
}
void
loop()
{
// turn on both pager motors to raise wings
pager1->run(FORWARD);
pager2->run(FORWARD);
// wait for wings to go up
delay(TIMEUP);
// turn off both pager motors to lower wings
pager1->run(RELEASE);
pager2->run(RELEASE);
// wait for wings to go down
delay(TIMEDOWN);
}
THANK YOU
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
Hi
I am using 2 DC motors on a motor shield with Arduino Uno.
Can someone please help me edit my code which is for a V2 shield to a V1 shield?
#include <Wire.h>
#include <AFMotor.h> //Include library AF Motor
#define SPEED 100
#define TIMEUP 1000
#define TIMEDOWN 1000
static Adafruit_MotorShield motors = Adafruit_MotorShield();
static Adafruit_DCMotor * pager1 = motors.getMotor(1);
static Adafruit_DCMotor * pager2 = motors.getMotor(2);
void
setup()
{
motors.begin();
pager1->setSpeed(SPEED);
pager2->setSpeed(SPEED);
}
void
loop()
{
// turn on both pager motors to raise wings
pager1->run(FORWARD);
pager2->run(FORWARD);
// wait for wings to go up
delay(TIMEUP);
// turn off both pager motors to lower wings
pager1->run(RELEASE);
pager2->run(RELEASE);
// wait for wings to go down
delay(TIMEDOWN);
}
THANK YOU
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
blh64
May 15, 2019, 3:39am
3
First, you need to make sure you have the version 1 library installed. Get it here
Then, look at the examples that come with that version of the library. It will show you how to do it.
Give it a shot. If you get stuck, read the sticky post at the top of this forum about how to post your code using code tags. Then, properly post your code and people will help
Woldn't it be easier if you tool a look at the datasheets and schematics yourself?
@tcantaro , please do not cross-post. Threads merged.