problem in sketch, need run motor

Hi guys, I have a project but I'm learning, for now I drive two servos in both directions with one jostyck ps2, my next step is to run an engine, but I am not able to, I need help.

use Arduino UNO and Arduino MEGA2560 and engine shield

link for shield:adafruit shield

And this my code for now:

// include the library code:

#include <Servo.h>

const int servo1 = 8;       // Servo 1
const int servo2 = 9;       // Servo 2
const int joyH = 3;        // IZquierda / derecha    Pin analogico
const int joyV = 4;        // Alante / atras         Pin analogico
int servoVal;           // variable para leer el valor del pin analogico

Servo myservo1;  // 
Servo myservo2;  // Crea un objeto,en este caso un servo




void setup() {

  // Servo  
  myservo1.attach(servo1);  // 
  myservo2.attach(servo2);  // attaches the servo

}


void loop(){

    // Lee el valor izquierda y derecha ( valor de 0 asta 1023 )
    servoVal = analogRead(joyH);          
    servoVal = map(servoVal, 1023, 0, 180, 0);              // Escala entre el 0 y 180

    myservo2.write(servoVal);                              // Establece la posicion deacuerdo al valor   

    // Lee el valor de arriba y abajo ( valor de 0 asta 1023 )
    servoVal = analogRead(joyV);           
    servoVal = map(servoVal, 1023, 0,180, 0);         // Escala entre ( 70 y 180 )

    myservo1.write(servoVal);                             // Establece la posicion deacuerdo al valor
    delay(15);                                           //  Tiempo de espera
 
}

I want to make a normal DC motor, with joistyckps2 such as servos work.
Any suggestions, I need help.

Thank you very much !!! a greeting

servoVal = map(servoVal, 1023, 0,180, 0);         // Escala entre ( 70 y 180 )

huh?

I want to make a normal DC motor, with joistyckps2 such as servos work.

Eh? Is it a normal DC motor OR a servo? They are totally different animals.

Hi, thanks for answering so fast.

The engine is a toy, is Dc normal rate.

Photo poyect

And I can not move it, any suggestions?

Tryiing to drive it as a servo will be useless. Servos are controlled by PWM. The PWM is purely a signal. It is incapable of driving a motor. Servos have the power supplied directly to them separately.

A DC motor needs an entirely different method of control. It will also need an independent power source as the arduino cannot provide enough power to drive a motor.

If it works, what and moved with UBN script Pueba, its library, with USB 5V the motor rotates, whether I can do without power feeding tests with over volts

motoreto:
If it works, what and moved with UBN script Pueba, its library, with USB 5V the motor rotates, whether I can do without power feeding tests with over volts

Sorry, I find this unintelligible. What is your first language?

KenF:
Sorry, I find this unintelligible. What is your first language?

IP says Spain.

we have a Spanish section in the forum

Trololo

motoreto:
Trololo

OK you had me :slight_smile:

the motor is run to 5V, only need code for joystick mode

Bi-directional control?
For that, you'll need either an H-bridge or a DPDT relay.
Either way, you can't power it from an I/O pin.

yeah men, look up the photo this is Driver motor H,and oficial page

motoreto:
yeah men, look up the photo this is Driver motor H,and oficial page

Are you still trolling us?

KenF:
Are you still trolling us?

You do not have eyes in your head? not see the photo and the shield and engine type and my doubt?