Phototaxis is commonly observed in motile photosynthetic microorganisms. For example, green algae are capable of swimming towards a light source (positive phototaxis) to receive more energy for photosynthesis, or away from a light source (negative phototaxis) to avoid radiation damage or to hide from predators. Recently, with the aim of applying nanoscale machinery to biomedical applications, various inorganic nanomotors based on different propulsion mechanisms have been demonstrated. The only method to control the direction of motion of these self-propelled micro/nanomotors is to incorporate a ferromagnetic material into their structure and use an external magnetic field for steering. Here, we show an artificial microswimmer that can sense and orient to the illumination direction of an external light source. Our microswimmer is a Janus nanotree containing a nanostructured photocathode and photoanode at opposite ends that release cations and anions, respectively, propelling the microswimmer by self-electrophoresis. Using chemical modifications, we can control the zeta potential of the photoanode and program the microswimmer to exhibit either positive or negative phototaxis. Finally, we show that a school of microswimmers mimics the collective phototactic behaviour of green algae in solution.