Triggering the push button on the analog input of the L293D motorshield
As noted in Nick Gammon's comment, digitalWrite(btnleft, INPUT) (etc.) would make a lot more sense than does analogWrite(btnleft, INPUT) (etc.).



Edit: INPUT is a constant defined in wiring.h (as in following extract), and is intended for use in pinMode() calls that set an IO pin's mode to one of INPUT, OUTPUT, or INPUT_PULLUP.  It's inept to use it in a call of either digitalWrite() or analogWrite().

    #define HIGH 0x1
    #define LOW  0x0    
    #define INPUT 0x0
    #define OUTPUT 0x1
    #define INPUT_PULLUP 0x2




Note that digitalWrite to an input-mode pin leaves the pin in input-mode, while an analogWrite to an input-mode pin changes the pin to output-mode.

When you want a pin to be input-mode with pullup, it is simpler to use INPUT_PULLUP as the mode parameter, rather than using two separate calls.  That is, instead of saying pinMode(pin, INPUT); followed by digitalWrite(pin, HIGH);, just say

pinMode(pin, INPUT_PULLUP);