An electronic device including an optical module, a method of operating the electronic device including the optical module, and a non-transitory computer-readable recording medium having recorded thereon a program for performing the method. The electronic device includes an optical module configured to project content on a projection surface and a processor configured to determine whether the electronic device is positioned within a predetermined range of a projection surface and control the optical module to project the content onto the projection surface based on the determination.