I am not sure what is going on with the frequency of this board but I am having a mental break down trying to figure it out. On top you see connections for pots, to read the control of the robot motors it is hooked too. However, In the code listed below it gets held up in finding a frequency for the board. I was wondering if you could take a look at the board I have pictured and the code and see if anything i have done is wrong? It will work sometimes, and other times it won't!
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
Adafruit_DCMotor *Motor1 = AFMS.getMotor(2);
int val0 = 0; // variable to store the Arm sensor
void input()// this is the subroutine that waits for the user to enter 1 for moving on or 2 for reading
{
int incomingByte = 0; // for incoming serial data
Motor1->setSpeed(0); // stop the motor
Serial.println("Hit return for next motion");
val0 = analogRead (0);
Serial.println(val0);
while (incomingByte != 49) // 13 is the ASCII code for "enter"
{
if (Serial.available() > 0)
{
// read the incoming byte:
incomingByte = Serial.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
}
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Adafruit Motorshield v2 - DC Motor test!");
Serial.println("Starting up controller!");
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
Serial.println("Controller has succsessfully !");
// Set the speed to start, from 0 (off) to 255 (max speed)
Motor1->setSpeed(150);
}
void loop()
{
Start: // come back to the beginning from the end
Serial.println ("Press Enter to start the Process:");
input(); // wait for user to hit enter
Serial.println("Starting");
val0 = analogRead (0);
Serial.print("val0 is ");
Serial.println(val0);
delay(100);
Serial.println("Forward");
if (val0 > 400)
{
while (val0 >400)
{
val0 = analogRead (0);
Serial.print ("value = ");
Serial.println (val0);
Motor1->setSpeed(100);
Motor1->run(FORWARD);
delay(5);
}
}
input(); // Wait for an enter to move the other direction.
Serial.println("Backward");
if (val0 < 637)
{
while(val0<637)
{
val0 = analogRead (0);
Serial.print ("value = ");
Serial.println (val0);
Motor1->setSpeed(100);
Motor1->run(BACKWARD);
delay(5);
}
}
goto Start;
}
Last edited by dagardner on Sat Apr 12, 2014 1:09 am, edited 1 time in total.
Your new photos don't show any of your soldering. We especially need to see the soldering on the SDA & SCL pins, as well as the power/ground and analog pin headers.
Your motor terminal soldering looks good. But many of your header pins appear to have too little solder. From what I can see, A4 has no solder at all. Please read through this guide and re-touch those header joints.
I am sorry if I am bothering you so much about the same problem, however, I was looking at the board to find anything and found that there was a little flux left on the board. I cleaned it the best of my ability using alcohol and q-tips. Now I only have one motor hooked up (M2) and the last three test I have done have been successful for for controller start up! I just wanted to give you this update and see what you thought about flux.
Burnt flux can be somewhat conductive and can cause problems.
On this shield, the important pins are: +5v, GND, A4 and A5. Note that A4 and A5 are cross-connected to SDA and SCL. Any problems with these pins could cause difficulty communicating with the board.