## 4 Implementation  
### Experimental SNR Measurement  
The SNR was measured to demonstrate the relationship between the communication distance, SNR, and exposure times. We can adjust the exposure time to achieve the desirable BER value and communication distance for the OCC system. In the experiment, we conducted many measurements  
Figure 4: Manchester code signal patterns and COOK received signal. (a) 0 impulse, (b) 1 impulse, (c) COOK received signal.  
Figure 3: (a) An experimental result of COOK within a rolling image. (b) The results of preamble position detection based on matched filter.  
for the distance between 5-20 m to calculate the SNR. As shown in Figure 5, we used LED (12-V, 3-W, 2 \(\times\) 2 cm\({}^{2}\) rectangle) as a transmitter and a rolling shutter camera (Point Gray) as a receiver. We also set up the exposure times of the camera in the range of 50-500 us with appropriate distance.  
The SNR was measured at a distance of 5, 10, 15, and 20 m (Figures 6-9). We can use two status of LED to calculate SNR. The first status of LED is ON, the SNR can be considered as the signal power of the LED and is displayed as a red line at a different distance. The second status of the LED is OFF, we used a blue line to display the SNR which can be awarded as background noise at this status. The SNR (dB) can be figured out based on the experiment by using the following equation:  
\[SNR_{dB}=20\log\left(\frac{\sqrt{\frac{1}{\hbar}\sum\limits_{i=0}^{n-1}{|A_{i} |}^{2}}}{\sqrt{\frac{1}{\hbar}\sum\limits_{i=0}^{n-1}{|B_{i}|}^{2}}}\right) \tag{2}\]  
here, A is represented for the signal power of the LED (i.e., pixel amplitudes which are measured when the LED turned on); B is represented for the background noise (i.e., pixel amplitude which is measured when the LED is turned off); and the number of measured samples is represented by n.  
Figure 5: Device for SNR measurement.  
Figure 6: SNR measurement with [PERSON] rolling shutter camera at communication distance of 5 m and exposure time of 50 μs.  
Figure 8: SNR measurement with [PERSON] rolling shutter camera at communication distance of 15 m and exposure time of 50 \(\upmu\)s.  
Figure 7: SNR measurement with [PERSON] rolling shutter camera at communication distance of 10 m and exposure time of 50 \(\upmu\)s.  
Figure 9: SNR measurement with [PERSON] rolling shutter camera at communication distance of 20 m and exposure time of 50 \(\upmu\)s.  
The received pixel amplitude values will be large at a short distance and small at a long distance. The shuttle speed and exposure time also affect the SNR calculation. The relationship between the SNR value and pixel intensity with a different exposure time of 50, 150, 300, and 50 us is illustrated clearly in Figure 7. The most important factor that affects the SNR is exposure time. In this scenario, the operation of the image sensor is similar to a low-pass filter. Since the high-tone signal will be smoothened when the exposure time is greater. Moreover, the communication bandwidth will go down as well which significantly affects to decrease in the total noise power spread over the bandwidth when the exposure time increases. Long exposure time also leads to the rise in the SNR. Besides that, the relationship between the SNR and the communication distance is illustrated in Figure 10. In the longer distance, the SNR value is reduced because of the power of light sources received in image sensors reduces. As we mentioned before, the matched filter is one of the linear filters to optimize the SNR of the system, then it also improves the communication distance. The comparison of COOK performance between zero-crossing and matched filter is illustrated in Section 4.4.