The project im working on: Short-Range Coded Visible Light communication System
Visible Light Communication (VLC) systems utilize light to transfer data between transmitter and receiver over short-range links. This project intends to build a wireless VLC system capable of transmitting voice between two microcontrollers such as Arduino or Raspberry pi using visible light. A Light Emitting Diode (LED) or Laser diode deployed at the transmitter side and a Light Dependent Resistor (LDR) or photodiode deployed at the receiving side. Data transmission via air with relatively high speed compared to radio-frequency communication systems. Digital data transmitted using on-off keying where the LED function as on-off light. Strings of ones (1) and zeros (0) are transmitted with high frequency such that the LED flicking is undetectable to the human eye. Both hardware (Arduino / Raspberry pi microcontroller) and software (MATLAB/ Arduino/ another software) are required for successful data transmission and reception.


Im using Arduino Uno and these are the codes that I used but im hearing noise from the speaker not my voice 


Transmitter code: 
// Define microphone pin
const int micPin = A0;

// Define LED pin
const int ledPin = 9;

// Define sampling frequency (in Hz)
const int samplingFrequency = 8000;

void setup() {
 // Set microphone pin as input
 pinMode(micPin, INPUT);
 
 // Set LED pin as output
 pinMode(ledPin, OUTPUT);

 // Begin serial communication at 9600 baud rate
 Serial.begin(9600);
}

void loop() {
 // Read analog voltage from microphone
 int analogValue = analogRead(micPin);

 // Map analog voltage to PWM duty cycle (0-255)
 int dutyCycle = map(analogValue, 0, 1023, 0, 255);

 // Set LED brightness based on duty cycle
 analogWrite(ledPin, dutyCycle);

 // Print duty cycle value to serial monitor
 Serial.println(dutyCycle);

 // Delay to maintain sampling frequency
 delay(1000 / samplingFrequency);
}


Receiver code: 

const int ldrPin = 9;
const int speakerPin = 11;
int voiceSample;

void setup() {
 Serial.begin(9600);
 pinMode(ldrPin, OUTPUT);
 pinMode(speakerPin, OUTPUT);
}

void loop() {
 analogWrite(ldrPin, voiceSample);
 delay(10);
 voiceSample++;
 if (voiceSample > 255) {
 voiceSample = 0;
 }
 int voiceInput = analogRead(A0);
 voiceInput = map(voiceInput, 0, 1023, 0, 255);
 analogWrite(speakerPin, voiceInput);
}