Electrochemical device captures carbon dioxide at the flick of a switch