Butterfly with Flapping Wings

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Butterfly with Flapping Wings

Post by kcl1s »

Because you will be reversing the motor ground and positive will change. You have the screw terminals installed so you just connect the 2 wires from your motor to the 2 M1 terminals. The photo at the top of this section of the guide shows clearly how to wire it. https://learn.adafruit.com/adafruit-mot ... -dc-motors
I have never used those motors but it looks like you will have to code them to move in one direction for an amount of time then the reverse direction for an amount of time then repeat. Make sure you go through the section of the guide on installing software to get the motor shield library installed. Here is a modified version of the example code that might work for your motor.

Code: Select all

/*
  This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
  It won't work with v1.x motor shields! Only for the v2's with built in PWM
  control

  For use with the Adafruit Motor Shield v2
  ---->	http://www.adafruit.com/products/1438
*/

#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Select which 'port' M1, M2, M3 or M4. In this case, M1
Adafruit_DCMotor *myMotor = AFMS.getMotor(1);
// You can also make another motor on port M2
//Adafruit_DCMotor *myOtherMotor = AFMS.getMotor(2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Adafruit Motorshield v2 - DC Motor test!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz

}

void loop() {
  myMotor->setSpeed(200);
  myMotor->run(FORWARD);
  delay(500);
  myMotor->run(BACKWARD);
  delay(500);
}
With those small motors you may be able to connect both motors to M1.

Keith

User avatar
tcantaro
 
Posts: 64
Joined: Mon Apr 29, 2019 3:06 pm

Re: Butterfly with Flapping Wings

Post by tcantaro »

Hi Keith,
I just want to make sure I understand. The photo shows one wire in M1 and the other in ground.

You’re saying that I put both wires in M1 and none in ground?

Can you please clarify.

User avatar
tcantaro
 
Posts: 64
Joined: Mon Apr 29, 2019 3:06 pm

Re: Butterfly with Flapping Wings

Post by tcantaro »

Hi Kevin,
If I want to use a battery that plugs into the metro board, how do i connect power to the motor shield?
Please let me know.
Attachments
Screen Shot 2019-05-13 at 9.00.21 AM.png
Screen Shot 2019-05-13 at 9.00.21 AM.png (814.77 KiB) Viewed 80 times

User avatar
kcl1s
 
Posts: 1512
Joined: Tue Aug 30, 2016 12:06 pm

Re: Butterfly with Flapping Wings

Post by kcl1s »

If I want to use a battery that plugs into the metro board, how do i connect power to the motor shield?
The shield has to have headers soldered on and mounted on top of the Metro to work as intended. Then read how to power from the board in the tutorial.
I just want to make sure I understand. The photo shows one wire in M1 and the other in ground.

You’re saying that I put both wires in M1 and none in ground?

Can you please clarify.
In the photo M1 has 2 screw terminals M2 has 2 screw terminals and a middle ground terminal for a total of 5 in that block. The motor leads are in the top 2 terminals so no connection to ground.

Keith

User avatar
tcantaro
 
Posts: 64
Joined: Mon Apr 29, 2019 3:06 pm

Re: Butterfly with Flapping Wings

Post by tcantaro »

Hi Keith
I need your help. What battery voltage should plug into the shield and what should go into the metro? I need to buy shipping today. Please help.

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”