Mic + Stepper motor = Movement?

Hello there!

I am extremely new to Arduino and wish to make a microphone input cause a stepper motor to move.

Items:

1 x Duemilanove board
1 x Motor shield board
1 x Electret Microphone
1 x Stepper motor (Mercury motor)

I have been able to gain readings from the microphone and separately control the motor via code (Yay me!)

But I have no idea how to make the two interact...

Is anyone able to help me?

I have attached a picture below so you can see what I am working with.

Thank you!

Image from Original Post so we don't have to download it. See this Simple Image Guide

...R

Your image doesn't really provide any useful information.

Please post the two working programs and also your best attempt at creating a composite program. Also tell us in detail what happens when you run the composite program.

...R

Hello Robin2, thank you very much for replying and sorry about the picture, I've read the guidelines you sent and will follow them through next time.

I'll try and add as much information as I can.

I have been experimenting with the example codes from the Arduino program and this as far as i have gotten.

Stepper motor control

#include <Stepper.h>

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);

int stepCount = 0;  // number of steps the motor has taken

void setup() {
  // declare the motor as an OUTPUT:
  Stepper (8 ,9 ,10, 11, OUTPUT);
  Serial.begin(9600);
}

void loop() {
    myStepper.setSpeed(100);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 200);
    Serial.println("HEY!! HELLO!!");
}

Microphone reading

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}

How far I have gotten

I have in the last couple of hours been tinkering with example code and found this gem! I think that I have gotten past my initial hurdle...and the motor works with some degree of input from the mic

#include <Stepper.h>

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);

int stepCount = 0;  // number of steps the motor has taken

void setup() {
  // nothing to do inside the setup
}

void loop() {
  // read the sensor value:
  int sensorReading = analogRead(A0);
  // map it to a range from 0 to 100:
  int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
  // set the motor speed:
  if (motorSpeed > 0) {
    myStepper.setSpeed(100);
    // step 1/100 of a revolution:
    myStepper.step(stepsPerRevolution / 200);
  }
}

This leads me to ask, how can i gain further control of the motor via volume? for example if it reaches a certain threshold what do i need to code in order to make it turn the other direction?

I don't know anything about the microphone side of your project.

What is the range of values you get from analogRead()?

Can you pick a value that represents the difference between forward and reverse?

If increasing volume increases speed how does the motor slow down before it reverses?

...R