Steppermotor help

Hey guys, i have a little problem i hope you can help me out :smiley:
I am useing a Sanguino board to start.
The PCB it is on has 5 buttons, one for +5 -5 +1 -1 steps on the motor and a go button. These are set to display on a LCD, however i cant seem to get anything to happen after i upload the program. Is there something i am doing wrong? Here is a copy of the program that was written for this task. I do understand i need to still tweak the variables for the motor however i believe i could get something to happen even if i dont have those veriables tweaked.

#include <LiquidCrystal.h>

// LiquidCrystal display with:
// rs on pin 1
// rw on pin 2
// enable on pin 3
// d0, d1, d2, d3 on pins 4, 5, 6, 7

LiquidCrystal lcd = LiquidCrystal(1, 2, 3, 4, 5, 6, 7);

int mot1 = 10;
int mot2 = 11;
int mot3 = 12;
int mot4 = 13;
int up = 14;
int down = 15;
int go = 16;
int down2 = 17;
int up2 = 18;
int goyes = 0;
int distance = 0;
//you need to change this to the value of how many cm/in you go per step
float distper_in = 0;
float distper_cm = 1;
//you need to change this to the value of how long it takes to go 1cm
float timeper_cm = 0;
int timet = 0;
//you might need to fiddle with this variable to get the stepper motor to work
//it is how many millisecconds it waits in between steps
int motime = 5;
void setup()
{
  pinMode(mot1, OUTPUT);
  pinMode(mot2, OUTPUT);
  pinMode(mot3, OUTPUT);
  pinMode(mot4, OUTPUT);
  pinMode(up, INPUT);
  pinMode(down, INPUT);
  pinMode(go, INPUT);
  pinMode(up2, INPUT);
  pinMode(down2, INPUT);

}

void start(void)
{
  while (goyes == 0)
  {
    if (digitalRead(up) == HIGH)
    {
      distance++;
      lcd.clear();
      lcd.print("dist:");
      lcd.print(int(distance * distper_in));
      lcd.print(int(distance * distper_cm));
      lcd.print(int(distance * timeper_cm));
    }
    if (digitalRead(down) == HIGH)
    {
      distance--;
      lcd.clear();
      lcd.print("dist:");
      lcd.print(int(distance * distper_in));
      lcd.print(int(distance * distper_cm));
      lcd.print(int(distance * timeper_cm));
    }
    if (digitalRead(up2) == HIGH)
    {
      distance += 5;
      lcd.clear();
      lcd.print("dist:");
      lcd.print(int(distance * distper_in));
      lcd.print(int(distance * distper_cm));
      lcd.print(int(distance * timeper_cm));
    }
    if (digitalRead(down2) == HIGH)
    {
      distance -= 5;
      lcd.clear();
      lcd.print("dist:");
      lcd.print(int(distance * distper_in));
      lcd.print(int(distance * distper_cm));
      lcd.print(int(distance * timeper_cm));
    }
    if (digitalRead(go) == HIGH)
    {
      goyes = 1;
    }
  }
}
  void runstuff(void)
  {
    timet = millis();
    //step 1
    while(goyes == 1)
    {
    if(distance != 0)
    {
    digitalWrite(mot1, HIGH);
    digitalWrite(mot2, LOW);    
    digitalWrite(mot3, HIGH);
    digitalWrite(mot4, LOW);
    distance--;
    delay(motime);
    }
    //step2
        if(distance != 0)
    {
    digitalWrite(mot1, LOW);
    digitalWrite(mot2, HIGH);
    digitalWrite(mot3, HIGH);
    digitalWrite(mot4, LOW);
    distance--;
    delay(motime);
    }
    //step3
        if(distance != 0)
    {
    digitalWrite(mot1, LOW);
    digitalWrite(mot2, HIGH);
    digitalWrite(mot3, LOW);
    digitalWrite(mot4, HIGH);
    distance--;
    delay(motime);
    }
    //step4
        if(distance != 0)
    {
    digitalWrite(mot1, HIGH);
    digitalWrite(mot2, LOW);
    digitalWrite(mot3, LOW);
    digitalWrite(mot4, HIGH);
    distance--;
    delay(motime);
    }
    if (distance == 0)
    {
      goyes = 2;
    }
  }
  }
  


void loop()
{
  if (goyes == 0)
  {
  start();
  }
  else
  {
    runstuff();
  }
  
  while(goyes == 2)
  {
  lcd.clear();
  lcd.print("time:");
  lcd.print(millis() - timet);
  lcd.print("dist:");
  lcd.print(int(distance * distper_in));
  delay(5000);
  }
  
  
  
}

the LCD part is defined here

#include <LiquidCrystal.h>

// LiquidCrystal display with:
// rs on pin 1
// rw on pin 2
// enable on pin 3
// d0, d1, d2, d3 on pins 5, 4, 3, 2

LiquidCrystal lcd = LiquidCrystal(1, 2, 3, 4, 5, 6, 7);

void setup
{
}

void loop
{
}

Any help you can give me would be very much appreciated
Thanks :slight_smile:

/ d0, d1, d2, d3 on pins 5, 4, 3, 2

If you’re using the LCD in four-bit mode, then you must connect D4, D5, D6 and D7 on the LCD to the Arduino’s pins.

alright to be honest i do not really know what you mean by that, i am useing a optrex japan PWB 24227-CEM LCD screen, i have traced the correct pins, and the ones from the code i posted above are going to the LCD. Also if the LCD screen works great. my biggest concern is the Motor, i can live without the screen.

the ones from the code i posted above are going to the LCD

You need to connect the LCD pins D4, D5, D6 and D7 to the Arduino, not the D0, D1, D2, D3 pins.

Also if the LCD screen works great

I don't understand this sentence. Is your LCD screen working properly or not?

oh ok, that makes sense now thanks. No what i mean is my primary concern is to get the steppermotor to work, if the LCD doesnt work it isnt the end of the world. I havent made the change you suggested yet though.

Hi, I have just foung the PWB 24227 display but I have no idea how to plug it in, do you have a datasheet?

Hi Kamis,

do you have a pin layout for the PWB 24227-CEM ?