Opto- and electro-mechanical entanglement improved by modulation