uno r3, dfr lcd keypad shield, and a servo... how to control?

so i have my uno r3, my 16x2 lcd keypad shield, and 2 servo's
what i want, is to be able to control servo-0 with left and right on the keypad
control servo-1 with up and down on keypad, and center out the servo's on keypad select button

tnap1979:
so i have my uno r3, my 16x2 lcd keypad shield, and 2 servo's
what i want, is to be able to control servo-0 with left and right on the keypad
control servo-1 with up and down on keypad, and center out the servo's on keypad select button

The first thing you need is to state what are the power requirements of each motor. I'll suppose they are small servos (below 1.2A), just so I can elaborate on an answer. If you are using larger, more powerful servos ignore everything from this point on, except for the "general idea" I am proposing.

Then you need to decide how you want to drive the servos.

Your options are:

  • self-built 4 H-bridges (2 for each servo)
  • 2 x L293D (1 for each servo)
  • 2 x L298N (1 for each servo)

Your arduino can't and shouldn't drive the servos directly, because the current required by the motors are much higher than what each arduino pin can provide. Therefore you should digitally drive the bridges or the ICs .

If you go down the IC route, I suggest you use a 74HC595 to serially drive the ICs, just so you can save a few pins from the Arduino, which you'll need to communicate with the parallel LCD.

then you'll have to decide how to power the motor-controller ICs (you power the ICs and the ICs power the motors). It is recommended that you use external power, different from the power of the Arduino. GND should be common, 'though.

Have lots of bypass/decoupling caps.

I have some experience with the L293D, because I just built myself a shield using it, including an on-board voltage regulator and digital voltmeter. Since there is only one L293D in my shield, I didn't use the 74HC595, but if I were using more than 1, using the 595 would have helped me save lots of pins.

Using the L293D is pretty straightforward and there are tons of documents in the internet explaining how to use it with the Arduino. The same goes for the 74HC595.

that sounds a tad complicated to my thought of = the keypad lcd shield i bought has 5 keys i can use, they are tied to analog0 and they output different values for each press, i want left and right, up and down keypad button press values to return a servo movement value indicated by the direction button pressed, i was under the impression that it would be simple sketch coding to translate say the left button pressed value to move the servo left certain value

my servos are getting power from a seperate 5v 5a input, the servo grounds are tied to arduino ground and power input ground, my servo signals are attached to available output pins

tnap1979:
my servos are getting power from a seperate 5v 5a input, the servo grounds are tied to arduino ground and power input ground, my servo signals are attached to available output pins

You should NEVER drive any kind of motor directly with your Arduino. Arduino output pins should only drive other ICs or at most very, VERY light loads (40mA max per pin, for a total combined value of about 350~400mA). Even small servos can easily reach 500mA when starting up or when under load.

Although it may work for very small servos, you are risking destroying your Arduino, and I won't take part in that.

these are hobby grade rc servos that get a pwm signal input, i was under the impression that the arduino uno can control these servos via a pwm output command on one of the pwm pins (3,5,6,9,10,11), as i have the "Teleduino" ethernetclientproxy sketch installed currently, and it controls these 2 servos just fine,

@Alx..... the tnap never said he was powering his servos from the Arduino, indeed he said he's powering them from externally, with control only from Arduino to servo, and tied grounds. That's SOP.

It's unnecessary to drive a servo from a chip like a 298, in fact I can't immediately picture how to do that. Purpose of a 298 or similar is to provide switching of the high voltage and current of a stepper or dc motor from a lower voltage / current device, with or without direction control.

Long as the servo power isn't from the Arduino, which it's not, it's cool.

tnap if your dfr shield is a dfr0009 or similar, have you looked at this? The code there shows how to recognise which button is pressed, so in each case segment where it finds a button you could drop in servo code. For example in the "select" part you could put...

   case btnSELECT:
     {
     lcd.print("SELECT");
     servo0.write(90);  ///////////////////////// new
     servo1.write(90);  ///////////////////////// new
     break;
     }

EDIT... with that dfr0009 shield, you're not left with many pins though- it only leaves 2, 3~, 11~, 12 and 13.

One potential problem I ran into using the DFRobot LCD keyboard shield is it wants to use pin 10 as the backlight control, presumably using PWM to control the power level of the back light and pin 9 as the enable bit. Unfortunately, on the Uno, the servo library disables pins 9 & 10 from being PWM pins (I believe it uses the interrupt that the normal library uses to do PWM on those pins). So at least in my limited test, I could not get the LCD keyboard shield and a servo to cooperate.

There is another problem with the LCD keyboard shield, and that is early versions of the LCD were mis-designed, and there were warnings to not use pin 10 at all. I don't remember the details at this stage, but you may have gotten an old shield that has been sitting on the shelf for awhile.

Unfortunately, on the Uno, the servo library disables pins 9 & 10 from being PWM pins (I believe it uses the interrupt that the normal library uses to do PWM on those pins). So at least in my limited test, I could not get the LCD keyboard shield and a servo to cooperate.

Good catch, Michael

Well, my lcd keypad shield is not a genuine dfr, it's a Chinese clone shield that has the same lcd control pins as a dfr unit (8,9,4,5,6,7) and the buttons are tied to analog0, other then that, I know nothing more about it, but I have had the lcd working with various tests including hello world and buttons display text

Yep but have you tried the shield when you have the servo library included in your sketch?

will do that shortly, but i thought i did,
how would i know what works and wont work
??

how would i know what works and wont work

Since servo takes away the PWM-ability of pins 9 and 10, and 10 is used for the lcd backlight, you probably won't be able to set the backlight with analogWrite(). But you should at least be able to set the backlight off and on with a digitalWrite(). I'll test that shortly too..... I'm surmising that's the only problem?

Btw, if your shield is laid-out like the DFR0009, those digital pins (or actually holes on mine) at top right of the board are, from right-to-left, 0, 1, 2, 3, 11, 12, and 13. They are not marked on the board, probably since there's no room.

this is a setup i made that does what i want it to do remotely,
but im making a small portable demo to show my friends and such and i just want to be able to use the lcd's keypad buttons to control demo servo's made to be like a camera mount, and possibly have the results of each keypress display on lcd, but dont want to push it.. lol

http://fritzing.org/projects/teleduino-controlled-pantilt-servo-webcam-mount/