I need you for my project for the baccalaureate (VNH5019 motor shield)

First of all I want to apologize for my level in English because I am French.

My project consists of detecting a can with an infrared sensor then if the can is detected, operate my servo motor, and finally, operate my electric cylinder to compact the can.

The problem is programming, because either the servo motor work but the electric cylinder does not work or the servo motor does not work but the electric cylinder work.

In my project I use, IR sensor, servo motor ( 6Voltage 2Ampere), motor shield 12A VNH5019 (for my electric cylinder) and electric cylinder ( 24Voltage 6Ampere)

When in void setup I write "md.init" before "servomotor.attach(11)" (in my program is Fragilisation.attach(11)),the eletric cylinder work but not the servomotor.
When I write "servomotor.attach(11)" before "md.init" the reverse happens

Thank you in advance for your help


But the pin 9 is used by the motor shield ? According to the datasheet, the pin 9 correspond to “Motor 1 speed input”

Programme_final.ino (796 Bytes)


I have already tried with the pin 3

Nobody can help me ? :frowning: :frowning: :frowning:


a, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins.

From the Servo library reference.

So pins 9 and 10 can’t be used for PWM if using the Servo library. You might have to get a different motor driver or find a way to route other pins to the driver. Or find a compatible servo library.

I used all available PWM pins.
So that would be because of the servo library that my shield does not work?
But why when I put the “md.init ()” function before “servo.attach (…)” the shield works?

Post a link to the motor shield.

Post links to the non-standard libraries you are using.

How are you powering the servo?

Shield : Pololu Dual VNH5019 Motor Driver Shield User’s Guide
Library motor shield : GitHub - pololu/dual-vnh5019-motor-shield: Arduino library for the Pololu Dual VNH5019 Motor Driver Shield
and I use the library Servo.h
I powered my servo motor with a laboratory power supply, I deliver 6 volts and 2 amps