I want to implement a simple VLC based communication system using two Arduinos and send messages/data/files between two PCs. For that I have a simple transmitter circuit with an LED on Tx side and a photo-transistor on the receiver side. The codes im using for transmission and reception are attached below, also the circuit image is attached below, but im unable to bring about any communication between the two PCs, the transmitter side works fine as the LED flickers indicating data is being transferred, but its not being received by the photo transistor. I don't know what im doing wrong. Any help would be appreciated, I am doing this as a part of my academics. Transmitter Code :

void setup()
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);

  // Clear Timer on Compare Match (CTC) Mode
  bitWrite(TCCR1A, WGM10, 0);
  bitWrite(TCCR1A, WGM11, 0);
  bitWrite(TCCR1B, WGM12, 1);
  bitWrite(TCCR1B, WGM13, 0);

  // Toggle OC1A and OC1B on Compare Match.
  bitWrite(TCCR1A, COM1A0, 1);
  bitWrite(TCCR1A, COM1A1, 0);
  bitWrite(TCCR1A, COM1B0, 1);
  bitWrite(TCCR1A, COM1B1, 0);

  // No prescaling
  bitWrite(TCCR1B, CS10, 1);
  bitWrite(TCCR1B, CS11, 0);
  bitWrite(TCCR1B, CS12, 0);

  OCR1A = 210;
  OCR1B = 210;


void loop()
  Serial.println("testing testing testing");

Receiver Code:

void setup()
  pinMode(13, OUTPUT);

void loop()
  // if incoming serial
  if (Serial.available()) {
    digitalWrite(13, HIGH);
  else {
    digitalWrite(13, LOW);
void readSerial() {
  char val = Serial.read();

the transmitter works fine, but the receiver is not receiving anything, I don't know what i'm doing wrong.

  • 2
    And how exactly are you wiring these components up? – Majenko Apr 17 '17 at 18:30
  • I thin a led may be too weak for this. Did you try to use a flashlight to check if you got any response with a more powerful source? Have you checked for interferences? Are you transmitting it in a dark room or in a illuminated room? I would suggest you to try to make a simpler circuit with just a photo-transistor and an arduino board and then print the output of the fototransistor to the serial so you can know how it behaves. – rvbarreto Apr 17 '17 at 19:19
  • I did a simple connection, Rx to phototransistor and through a resistor to pin 13. thats it – D_batmaniac Apr 17 '17 at 20:01
  • 1
    @D_batmaniac I don't follow you. Please draw full schematics of both ends. – Majenko Apr 17 '17 at 21:06
  • 3
    I'm voting to close this question as it has been abandoned without ever presenting an attempt that actually accomplishes anything - the alleged transmit code here transmits no information, at most it simply blinks an LED at a steady rate, and no viable receive code has been provided. Repeated requests for the wiring have not been honored. – Chris Stratton Oct 15 '17 at 19:12

The amplitude of the signal at the photodetector is small. Better use ADC for reading.

  • The problem is even more fundamental - there's not only no viable encoding scheme being used, there's actually no data being transmitted at all. – Chris Stratton Oct 15 '17 at 19:11

I think you have problem with your hardware side. I would like to suggest a few things; maybe it will work.


Instead of a normal LED use an IR LED because it has advantages over normal led for transmission of data like it is more secure, support max transmission speed, less power consumption, and much more. For transmitter of signal use the following circuit. Ihave used TSOP1738 for receiver, so we need to generate the modulated IR of 38 kHz. You can use any TSOP, but you need to generate IR of respective frequency as TSOP. So using 555 timer in Astable mode to oscillate the IR at 38KHz frequency. As we know oscillation frequency of 555 timer is decided by resistor R1, R2 and capacitor C1. We have used a 1k R1, 20K R2 and 1nF capacitor to generate a frequency of approx. 38 KHz. It can be calculated using this formula: 1.44/((R1+2*R2)*C1)

enter image description here

and instead of a push button you can use a transistor or mosfet as switch, which will be controlled with a controller.


I don't know which phototransistor you are using but I'll suggest to use a TSOP17XX. TSOP17XX receives the modulated Infrared waves and changes its output. TSOP is available in many frequency ranges like TSOP1730, TSOP1738, TSOP1740 etc. The last two digits represent the frequency (in Khz) of modulated IR rays, on which TSOP responds. Like for example TSOP1738 reacts when it receives the IR radiation modulated at 38Khz. Means it detects the IR which is switching On and Off at the rate of 38Khz. TSOP’s output is active low, means its output is remains HIGH when there is no IR, and becomes low when it detects IR radiation. TSOP operates on particular frequency so that other IRs in the environment can’t interfere, except the modulated IR of particular frequency.

To receive the data here is some simple circuitry:

enter image description here

Instead of LED connect that pin to your receiver controller; you will get the signal properly. Hope this works for you.

Please try to perform our experiment in a noiseless (IR free) environment to get the correct output.

Reference: https://bit.ly/2PBtvYp


Your receiver(ldr) might not be accurate enough, rather try using an led as a receiver as well. You will just need to boost the signal then with something like a 1Mohm resistor in parallel with the receiving led.

You can use something like this as well, haven't tried it but it looks like it will work: http://www.instructables.com/id/Arduino-Communication/ maybe just a 1Mohm resistor instead of the 1Kohm one

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.