I have the below code working to spin a stepper motor. I have the arduino connected to an .mp3 card, but need to add the code to get it to play. I have added what I believe is the correct code (see below in red). Any help is appreciated. Thanks in advance
EDIT: Using CODE tags makes it easier for others to see your code.
C:
/*
Stepper Motor Control - one revolution
This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.
The motor should revolve one revolution in one direction, then
one revolution in the other direction.
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe
*/
#include <Stepper.h>
int x = 0;
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(63);
// initialize the serial port:
Serial.begin(9600);
}
void loop() {
if (x <= 10)
{ // step one revolution in one direction:
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
// delay(500);
x++;
}
// step one revolution in the other direction:
// Serial.println("counterclockwise");
// myStepper.step(-stepsPerRevolution);
// delay(500);
}
[COLOR=red][B]
void setup(){
Serial.begin(4800);
}
void loop(){
Serial.write(0x01);[/B][COLOR=#000000]
Last edited by a moderator: