How to connect arduino to a motor and control its speed (with makey makey)

hey guys,

we are trying to control a stepper motor with arduino. While the motor is turning we would like to control the speed.
The arduino should be connected to a makey makey so for example we can push a banana and in cause of that the motor speeds up.

Does anybody have a code or an other idea how to control the speed of a motor with makey makey and arduino???

The whole work is for an art installation in the university. We are under pressure of time...
So please, if you can help us, answer us as quickly as possible!

THANKS a lot...

Hey guys,

i'm working on a art installation for university.

I found this code :

/* Pins to Configure the Displacement of the Stepper Motor (on the Easy Driver):
//////////////////////////////////////////////
// MS1 MS2 //
// //
// LOW LOW = Full Step //
// HIGH LOW = Half Step //
// LOW HIGH = A quarter of Step //
// HIGH HIGH = An eighth of Step //
// //
//////////////////////////////////////////////
*/

#define step_pin 3 // Define pin 3 as the steps pin
#define dir_pin 2 // Define pin 2 as the direction pin
#define MS1 5 // Define pin 5 as "MS1"
#define MS2 4 // Define pin 4 as "MS2"

int direction; // Variable to determine the sense of the motor
int steps = 200; // Number of steps that you want to execute (for full steps, 200 = 1 turn)

void setup() {
pinMode(MS1, OUTPUT); // Configures "MS1" as output
pinMode(MS2, OUTPUT); // Configures "MS2" as output
pinMode(dir_pin, OUTPUT); // Configures "dir_pin" as output
pinMode(step_pin, OUTPUT); // Configures "step_pin" as output
digitalWrite(MS1, LOW); // Configures the steps division (see above)
digitalWrite(MS2, LOW); // Configures the steps division (see above)
digitalWrite(dir_pin, LOW); // Sense (HIGH = anti-clockwise / LOW = clockwise) - It can be also changed
}

void loop() {
while(steps>=0) { // While the steps value is greater or equal zero
digitalWrite(step_pin, HIGH); // Sends logic level 'high' to the steps pin of the motor
delay(5); // Waits 5ms for the next step
digitalWrite(step_pin, LOW); // Sends logic level 'high' to the steps pin of the motor
delay(5); // Waits 5ms for the next step
steps--; // Decrements the "steps" variable

}
}

to turn a motor. Now my question is it possible to change this code to an infinity loop? So the motor will turn the whole time?

AND is there any possibility that i can push for example a button on my keyboard an the motor speeds up or down?

Thanks for help

http://forum.arduino.cc/index.php/topic,148850.0.html

See number 7, using code tags.

Now my question is it possible to change this code to an infinity loop? So the motor will turn the whole time?

Change

while (steps>=0) {    // While the steps value is greater or equal zero

to

while (true) {    // loop forever

AND is there any possibility that i can push for example a button on my keyboard an the motor speeds up or down?

Yes, use a variable for the delay instead of 5,

Hey MarkT,

you just answered a question of mine. I'm working on this project but i'm "just" studying architecture. So my knowledge about arduino is very low.

Would it be possible for you to answer some question for me?

Thanks a lot...