Help!!! Control Stepper Motor Shield + Arduino YUN

Hi,

I have a problem with Motor Shield, I've created a sketch to control de stepper motor from Arduino with Wii Nunchuck and this sketch run grateful in Arduino UNO but this not run in Arduino YUN, and i need help to understand this issue.

Following is the sketch:

#include <Wire.h>
#include <WiiChuck.h>
#include <Stepper.h>


const int ppr = 200;//passos totals per fer una volta
Stepper stepper1(ppr, 12,13);

WiiChuck chuck = WiiChuck();

 const int pwmA = 3;
 const int pwmB = 11;
 const int brakeA = 9;
 const int brakeB = 8;
 const int dirA = 12;
 const int dirB = 13;
int vel = 40;
void setup() {
  
  Serial.begin(115200);
  chuck.begin();
  chuck.update();
  pinMode(pwmA, OUTPUT);
 pinMode(pwmB, OUTPUT);
 pinMode(brakeA, OUTPUT);
 pinMode(brakeB, OUTPUT);
 digitalWrite(pwmA, HIGH);
 digitalWrite(pwmB, HIGH);
 digitalWrite(brakeA, LOW);
 digitalWrite(brakeB, LOW);
 stepper1.setSpeed(50);

  //chuck.calibrateJoy();
}

void loop() {
  delay(20);
  chuck.update(); 

  
  Serial.print(chuck.readJoyY());
    Serial.print(", ");  
 
    Serial.println();

if(chuck.readJoyY() > 7 && chuck.readJoyY() < 40){
  stepper1.setSpeed(10);
  stepper1.step(1);
   

}

else if(chuck.readJoyY() > 40 && chuck.readJoyY() < 60){
  stepper1.setSpeed(vel);
  stepper1.step(5);

  if(vel<30){
      vel++;
  }

}

else if(chuck.readJoyY() > 60 && chuck.readJoyY() < 80){
    stepper1.setSpeed(80);
  stepper1.step(10);
  

}

else if(chuck.readJoyY() > 80 ){
    stepper1.setSpeed(100);
  stepper1.step(15);

}



else if(chuck.readJoyY() < -30 && chuck.readJoyY() > -50){
   stepper1.setSpeed(40);
  stepper1.step(-1);
}

else if(chuck.readJoyY() < -50 && chuck.readJoyY() > -80){
   stepper1.setSpeed(60);
  stepper1.step(-5);
}

else if(chuck.readJoyY() < -80 && chuck.readJoyY() > -100){
   stepper1.setSpeed(80);
  stepper1.step(-10);
}

else if(chuck.readJoyY() < -100){
   stepper1.setSpeed(100);
  stepper1.step(-15);
}
 
else 
  stepper1.step(0);



}

Thanks, and sorry for my bad English.

You should check out the differences between a uno and a leonardo (the yun shares the same microcontroller and pins). Morever, remember that the yun uses pins rx/tx (hardware serial) to communicate with the linux side. If you shield/tft screen requires a serial, you need to hook it up other pins and use SoftwareSerial

Thank you very much Federico!!
But now I don't have a idea how to make this, I'd be very grateful if you could guide me a little with this, I see the SoftwareSerial Library but I don't know what have to do exactly.

Thanks again.

Take a look here: http://arduino.cc/en/Reference/SoftwareSerial and look for "leonardo" in the Limitations paragraph

Federico've been reading about the library and I can not understand SoftwareSerial, I have not seen any example of how it works with Yun Arduino or Arduino Leonardo and any shield, I also looked at the mapping of both ATMEGA32U4 and 328, and have seen the differences , but I can not relate that to the library SoftwareSerial, please would greatly appreciate any example or explanation of how you have to use SoftwareSerial for Arduino Motor Shield.

Thanks

I have not seen any example of how it works with Yun Arduino or Arduino Leonardo

There is an axample on the page Federico mention

Yes, thanks Erni, but I don't understand how to apply this example to Arduino Motor Shield, understand that SoftwareSerial allows using certain pins as tx and rx, but still applying the example can not get it to work the Motor Shield, sorry for my inexperience I am a beginner in Arduino.

Thank You very much!!

I used the following code:

SoftwareSerial mySerial(10, 4); //set rx and tx
 
 // motor control pins names
 const int pwmA = 21;
 const int pwmB = 31;
 const int brakeA = 17;
 const int brakeB = 15;
 const int dirA = 27;
 const int dirB = 1;

I used the corresponding pins of atmega328 in ATMEGA32U4, in this case the tx corresponds to 3 in UNO and 21 in YUN, and so successively, I also used SotwareSerial for use as rx and tx pins 10 and 4. And still does not work.. I hope can help me, thanks!