ive got my main code but its dependant on audio
thi is a test code, on the original draft user was using a different motor shield
i am using the v2 motorshield
ive added the lines to included the library at the top of the code
but to test my motors, how do i rename it in the rest of the code?
included screenshot with wrror, and code below. just wanted to test the 3 motors in sequence to make sure the motors are done correctly
#include <Adafruit_MotorShield.h>
#define NUM_MOTORS 3
AF_DCMotor head(1, MOTOR12_1KHZ);
AF_DCMotor mouth(2, MOTOR12_1KHZ);
AF_DCMotor tail(3, MOTOR34_1KHZ);
AF_DCMotor motors[NUM_MOTORS] = {head, mouth, tail};
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println("Motor test!");
for (int i = 0; i < NUM_MOTORS; i++) {
motors[i].setSpeed(255);
}
}
void runMotorOnOff(AF_DCMotor motor, int animationDelay = 500) {
motor.run(FORWARD);
delay(animationDelay);
motor.run(BACKWARD);
delay(5);
motor.run(RELEASE);
delay(animationDelay / 2);
}
void loop() {
runMotorOnOff(head, 1000);
runMotorOnOff(mouth, 500);
runMotorOnOff(tail, 1000);
}
If that works, then you can try with three motors.
The difference between a beginner and a advanced Arduino user is that a beginner tries to rush to the end result, and a advanced Arduino user does a project step by step.
i already figured it out. whos rushing anything? i ask questions as i go, as anybody whos EAGER to learn will. you were once new too buddy, Communities are there to ask questions and work together.
Sure I was a newcomer too. And as a newcomer beeing un-experienced I wrote programs this way:
write minimum 100 lines of code and then start testing.
The result was: I had 5 bugs in the code which where influencing each other.
So with trying to correct the first bug this took me a lot of time because there were so many lines of code which caused the bug.
It took looong to find the first bug.
Then I tried to do a "quick fix" without fully understanding my own code.
This caused aditional bugs.
All in all it took 50 hours to make the code work
Today (and as each every experienced and / or professional software-developper) I write code this way:
Write a simple test-program which has only a few lines of code and test it until this testcode works reliable. This took 1 hour time.
Then testing the next small thing
Write a simple test-program for the "second" function which has only a few lines of code and test it until this testcode works reliable. This took 1 hour time.
Putting those two functions together and test again
took 0,5 hours time
repeated this with the next three functions and have the code up and running
after 7 hours. Compared to 50 hours with a lot of head-scratching and frustration.
And additionally doing modifications of the code and test them runs down pretty quick.
You can have "luck" that throwing together parts of other peoples code does work.
Seems to be so in your case. And this might lead to a programming-style of writing many lines then start testing.
Experienced users try to help you with saying: in the long run adding one thing at a time then immitiately test will finish your project faster because searching for the bug will be fast as there are only a few lines to search through!