Pages: [1]   Go Down
Author Topic: Urgent: Need help regarding high pitched sound from non-functioning DC motor  (Read 707 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone. I urgently need help regarding a squealing high pitched sound coming from the DC geared motors I'm using in my robot. Here is a schematic of it. My apologies for the hand drawn diagram.



Also, here is the code I'm using:

Code:

#include <JoystickShield.h>
#include <Servo.h>

// pins for motor outputs
int motor_pin1 = 4;      //assignes a pin number to the output terminal of the gear motor
int motor_pin2 = 5;
int motor_pin3 = 6;
int motor_pin4 = 7;

JoystickShield joystickShield; // create an instance of JoystickShield object

void setup ()
{
  // pinModes for motor outputs
  pinMode(motor_pin1,OUTPUT);  //telling Arduino that the given pin is to be used as output
  pinMode(motor_pin2,OUTPUT);
  pinMode(motor_pin3,OUTPUT);
  pinMode(motor_pin4,OUTPUT);
}

void loop ()
{
  joystickShield.processEvents(); // process events

  if (joystickShield.isUp())
  {
     forward();
  }

  if (joystickShield.isRightUp())
  {
     turnright();
     forward();
  }

  if (joystickShield.isRight())
  {
     turnright();
  }

  if (joystickShield.isRightDown())
  {
     turnright();
     backward();
  }

  if (joystickShield.isDown())
  {
     backward;
  }

  if (joystickShield.isLeftDown())
  {
     turnleft();
     backward();
  }

  if (joystickShield.isLeft())
  {
     turnleft();
  }

  if (joystickShield.isLeftUp())
  {
     turnleft();
     forward();
  }
 
  else
  {
    halt();
  }
}

void forward()
{             
   digitalWrite(motor_pin1,LOW);
   digitalWrite(motor_pin2,HIGH);
   digitalWrite(motor_pin3,HIGH);
   digitalWrite(motor_pin4,LOW);
   return;
}

void backward()
{
  digitalWrite(motor_pin1,HIGH);
  digitalWrite(motor_pin2,LOW);
  digitalWrite(motor_pin3,LOW);
  digitalWrite(motor_pin4,HIGH);
  //delay(500);
  //halt();
  return;
}

void halt ()
{
  digitalWrite(motor_pin1,LOW);
  digitalWrite(motor_pin2,LOW);
  digitalWrite(motor_pin3,LOW);
  digitalWrite(motor_pin4,LOW);
  //delay(500);                          //wait after stopping
  return;
}

void turnleft ()
{
  digitalWrite(motor_pin1,LOW);       
  digitalWrite(motor_pin2,HIGH);      //right motor rotates forward and left motor backward
  digitalWrite(motor_pin3,LOW);
  digitalWrite(motor_pin4,HIGH);
  //delay(1000);                     // wait for the robot to make the turn
  //halt();
  return;
}

void turnright ()
{
  digitalWrite(motor_pin1,HIGH);       
  digitalWrite(motor_pin2,LOW);    //left motor rotates forward and right motor backward
  digitalWrite(motor_pin3,HIGH);
  digitalWrite(motor_pin4,LOW);
  //delay(1000);                              // wait for the robot to make the turn
  //halt();
  return;
}


When I test my motors and the joystick separately, they work perfectly fine. However, the moment I hook them up as shown in the diagram, the motor starts producing a high pitched sound and stops working.

Here are the components I'm using:

Sparkfun Joystick Shield: https://www.sparkfun.com/products/9760
DC Geared motor: http://www.nex-robotics.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=714&category_id=31&option=com_virtuemart&Itemid=45
Standard servo: http://www.nex-robotics.com/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=816&category_id=217&option=com_virtuemart&Itemid=45

I need to present this robot  in a competition, in exactly 7 more hours and it's already 11:30 in the night here  smiley-confuse . I'd really appreciate it if someone could help me out as soon as possible.

I'm so sorry for posting this question under two separate subjects, but I'm desperate for an answer at this hour. Please help me.

Thanks.
« Last Edit: October 23, 2013, 01:25:31 pm by popoya » Logged

Pages: [1]   Go Up
Jump to: