need help with stepper and IR remote

This is my first time using an Arduino board and I am super excited. I am trying to set up a stepper to constantly rotate when I hit the up button on my IR remote. I have it set up now to do a full rotation cw when I hit up and a full ccw rotation when I hit the down button. I need this to spin one direction when I hit up and the other when I hit down. This is for a toy that constanlty will be spinning

Here is the code I am using

#include "Stepper.h"
#include "IRremote.h"

/----- Variables, Pins -----/
#define STEPS 64 // Number of steps per revolution of Internal shaft
int Steps2Take; // 2048 = 1 Revolution
int receiver = 6; // Signal Pin of IR receiver to Arduino Digital Pin 6

/-----( Declare objects )-----/
// Setup of proper sequencing for Motor Driver Pins
// In1, In2, In3, In4 in the sequence 1-3-2-4

Stepper small_stepper(STEPS, 8, 10, 9, 11);
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results; // create instance of 'decode_results'

void setup()
{
Serial.begin(9600); //NEW TEST
Serial.println("IR Receiver Raw Data + Button Decode Test"); //NEW TEST
irrecv.enableIRIn(); // Start the receiver
}
//NEW
/-----( Declare User-written Functions )-----/
void translateIR() // takes action based on IR code received

// describing Car MP3 IR codes

{

switch(results.value)

{

case 0xFF906F:
Serial.println(" up ");
break;

case 0xFFE01F:
Serial.println(" DWN ");
break;

case 0xFFA25D:
Serial.println(" PWR ");
break;

case 0xFF629D:
Serial.println(" VOL+ ");
break;

case 0xFFE216:
Serial.println(" STOP ");
break;

case 0xFF22DD:
Serial.println(" BACK ");
break;

case 0xFF02FD:
Serial.println(" PLAY ");
break;

case 0xFFC23D:
Serial.println(" FF ");
break;

case 0xFFA857:
Serial.println(" VOL- ");
break;

case 0xFF6897:
Serial.println(" 0 ");
break;

case 0xFF9867:
Serial.println(" EQ ");
break;

case 0xFFB04F:
Serial.println(" ST ");
break;

case 0xFF30CF:
Serial.println(" 1 ");
break;

case 0xFF18E7:
Serial.println(" 2 ");
break;

case 0xFF7A85:
Serial.println(" 3 ");
break;

case 0xFF10EF:
Serial.println(" 4 ");
break;

case 0xFF38C7:
Serial.println(" 5 ");
break;

case 0xFF5AA5:
Serial.println(" 6 ");
break;

case 0xFF42BD:
Serial.println(" 7 ");
break;

case 0xFF4AB5:
Serial.println(" 8 ");
break;

case 0xFF52AD:
Serial.println(" 9 ");
break;

default:
Serial.println(" other button ");

}

delay(500);

} //END translateIR
//NEW

void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?

{
switch(results.value)

{

case 0xFF906F: // UP button pressed
small_stepper.setSpeed(500); //Max seems to be 700
Steps2Take = 2048; // Rotate CW
small_stepper.step(Steps2Take);
delay(2000);
break;

case 0xFFE01F: // DOWN button pressed
small_stepper.setSpeed(500);
Steps2Take = -2048; // Rotate CCW
small_stepper.step(Steps2Take);
delay(2000);
break;

}

irrecv.resume(); // receive the next value
}

}/* --end main loop -- */

Why would you choose a stepper motor, that provides precise positioning, for a toy that constantly spins. That is the wrong hardware.

In any case, loop() loops. When the CW button is pressed, set a flag that indicates that CW rotation is required. When the CCW button is pressed, clear the CW flag and set a flag that indicates that CCW rotation is required.

If rotation is required, because a flag is set, step ONCE.

You'll need another button to stop the fool thing.

This is my first time using an Arduino board and I am super excited.

So excited, in fact, that you posted the same question, equally badly, twice.
Please don't bother wasting your precious time looking for the other post, because I deleted it.

Hi Fezfett
Do not get too disheartened re wrong hardware I suspect you may have got some steppers for nothing maybe from a old printer. I enjoy finding salvage and have picked up a lot of steppers sensors and many other items.

I am currently working on a project using a stepper and have had a lot of hassles finding simple examples to copy understand and modify.

Trouble is my 78 year old brain sometimes is slow.

For my project I am using a EasyDriver

I used a sketch from

SparkFun Easy Driver Basic Demo

( Simple demo sketch to demonstrate how 5 digital pins can drive a bipolar stepper motor,
using the Easy Driver (EasyDriver - Stepper Motor Driver - ROB-12779 - SparkFun Electronics). Also shows the ability to change
microstep size, and direction of motor movement.)

have a look at this
Index of /EasyDriver/Examples

I finally was able to drive my motor with modifications from the original (still needs cleaning up)

You may find some help in the code I ended up with !!

[code]
//\DEMO FOR DIFFERNT FUNCTION 
//Modified to run motor for adjustable no of steps set at 10000

/**ENABLE TO BE USED ADD BUTTON TO BOTTOM
  SparkFun Easy Driver Basic Demo
  Toni Klopfenstein @ SparkFun Electronics
  March 2015
  https://github.com/sparkfun/Easy_Driver

  Simple demo sketch to demonstrate how 5 digital pins can drive a bipolar stepper motor,
  using the Easy Driver (https://www.sparkfun.com/products/12779). Also shows the ability to change
  microstep size, and direction of motor movement.


  Example based off of demos by Brian Schmalz (designer of the Easy Driver).
  http://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html
******************************************************************************/
//Declare pin functions on Redboard
#define stp 2
#define dir 3
#define MS1 4
#define MS2 5
#define EN  6

//Declare variables for functions
char user_input;
int x;
int state;

void setup() {

  pinMode(stp, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(MS1, OUTPUT);
  pinMode(MS2, OUTPUT);
  pinMode(EN, OUTPUT);

  resetEDPins(); //Set step, direction, microstep and enable pins to default states
  Serial.begin(9600); //Open Serial connection for debugging
  Serial.println();
  //Print function list for user selection
  Serial.println("Enter number :");
  Serial.println("1. START AND RUN .");

  Serial.println();
}

//Main loop
void loop() {
  while (Serial.available()) {
    user_input = Serial.read(); //Read user input and trigger appropriate function
    digitalWrite(EN, LOW); //Pull enable pin low to allow motor control THIS CAN BE USED TO START AND STOP
    if (user_input == '1');
    StepForwardDefault();
  }
  {
    {
    }


    {

    }
    resetEDPins();
  }
}

//Reset Easy Driver pins to default states
void resetEDPins()
{
  digitalWrite(stp, LOW);
  digitalWrite(dir, LOW);
  digitalWrite(MS1, LOW);
  digitalWrite(MS2, LOW);
  digitalWrite(EN, HIGH);
}

//Default microstep mode function
void StepForwardDefault()
{
  Serial.println("Moving forward at default step mode.");
  digitalWrite(dir, LOW); //Pull direction pin low to move "forward"
  for (x = 1; x < 10000; x++) //Loop the forward stepping  for adjustable no of steps
  {
    digitalWrite(stp, HIGH); //Trigger one step forward
    delay(1);
    digitalWrite(stp, LOW); //Pull step pin low so it can be triggered again
    delay(1);
  }
}


I also made the mistake of posting twice when I forgot to include my code and it also was deleted. 

Now have to add another modified sketch to stop and start and am getting there slowly.

Good luck and keep at it. 

Beckett

[/code]