In this paper, an online to offline (O2O) method based on visible light communication (VLC) is proposed, which is different from the traditional VLC with modulation and demodulation. It is a new VLC with modulation and recognition. We use RGB light emitting diode (RGB-LED) as the transmitter, and use Pulse Width Modulation (PWM) to modulate the signal to make it flicker at high frequency. Therefore, several features are created. At the receiver, the complementary metal-oxide-semiconductor (CMOS) image sensor is applied to our system to capture LED images with stripes. A convolution neural network (CNN) is then introduced in our system as a classifier. By offline training for the classifiers and online recognition of LED-ID, the scheme proposed could improve the speed of LED-ID (the unique identification of each different LED) identification and improve the robustness of the system. This is the first application of CNN in the field of VLC.