Improvements for measurements of the response time of a LDR

Hi everyone
First about the background of my project. I want to transmit data (for example pictures, see Base64) with a laser pointer/a laser diode (using a LED at the moment). As a receiver I want to use an LDR (I know they are slow, but I couldn’t get something better yet). I heard photodiodes would work great in combination with a transimpedance amplifier. But I’m also open for other ideas. I want to use the ASCII code so I need 7 bits for each characters. Over a voltage divider with the LDR the arduino receives the data. Now I need to know how many bits per sec a LDR voltage divider can distinguish (high = 1, low = 0). To figure this out I wrote a short program.
Short summary how the program works:
Arduino1 tells Arduino2 via a voltage divider (Can you use rx/tx here? How?) that he will turn on the LED for x microseconds. Then Arduino2 starts a timer. If he gets a high from the voltage divider with the LDR he stops the time. Then he waits for that the Pin becomes low and stops the time again. Finally he sends the measured times to the serial monitor. Now you can calculate the response time of the LDR.

I attached a drawing of the circuit for better comprehension.

I’d be really happy about some improvements for my code, how to make it faster respectively to make the measurements more accurate.

My code:

Arduino1

void setup() {
Serial.begin(9600);
DDRB = DDRB | B110000;
}

void loop() {
  //Start the test with an 1 on the serial monitor
  if(Serial.available()>0){
  if(Serial.read()==49){
    //Used for debug
    Serial.println("check");  
    //Turn on the LED and tell Arduino2 to start the timer
    PORTB = B110000;
    //Wait...
    delayMicroseconds(1500);
     //Turn off the LED 
     PORTB = 0;
     //Wait again for the next try..
     delay(1000);
     Serial.println("ready");
    }
  }
}

Arduino2

long zeit = 0;
long zeit2 = 0;
long zeit3 = 0;
int statu = 0;
int eingang = 0;

void setup() {
  Serial.begin(9600);
  pinMode(10, INPUT);
  }
  
  void loop(){
    //Wait for Arduino1
    eingang = PINB;
    eingang &= 16;
    if (eingang == 16) {
      //Start the timer
      zeit = micros();
      //Wait for the LDR
      while (statu != 48) {
        statu = PINB;
        }
        //Save the measurements
        zeit2 = micros();
        zeit2 -= zeit;
        //Wait for Low
        while(statu == 48){
          statu = PINB;
          }
        zeit3 = micros();
        zeit -= zeit;
        Serial.println(zeit2);
        Serial.println(zeit3);
        //Reset the variables
        zeit = 0;
        zeit2 = 0;
        zeit3 = 0;
        statu = 0;
        //Wait for the next try
        delay(1000);
        Serial.println("ready");
        }
        }

Best wishes

AresLoom

Why 2 Arduinos?

For measuring response times I'd use only one, remember the time and light the LED, then wait for the LDR to respond, and again take the time. The same for turning the LED off.

What about just using an infra red system.

Another thing you might consider using is an Android phone and Bluetooth - see this RemoteXY Thread.

...R