Optical microscopy is a simple, yet essential, imaging technology. Conventional laboratory-grade optical microscopes are bulky and costly, confining their use to within laboratory settings and restricting their accessibility in regions of limited resources. With the aim of overcoming these limitations, we have realized a portable, low-cost, and highly automated optical microscope that integrates mass-manufactured components, including light-emitting diodes, a web camera, optical disk drives, and a microcontroller. Our implementation is capable of bright-field and fluorescence imaging with micrometer-scale resolution and controlled mechanical actuation of both the lens and sample. We interface the lighting, image capture, and mechanical actuators of the microscope into a single software environment, enabling automation of common microscope operations, such as image focusing and large-area sample visualization. Combination of mechanical actuation and software automation into a compact, low-cost microscope system is an important initial step toward the goal of making optical microscopy universally accessible, portable, and easy to use.