## Introduction: Laser Data Transfer, Part2- Binary Transmitting.

in part1, I have shown a simple way to transmit data over laser. it depend originally on time, such that if we transmit 1 the laser light up for 200ms and if 3 the laser light up for 400ms, then the receiver measure the time of the pulse, and finally print the number sent on LCD.

here I made some improvement, I only send the numbers 0 and 1, depinding on the ASSCI representation of the data sent.

in this way, you can send any char you want using 2 arduinos, laser and LDR. and you can display the data on an LCD.

all the details about the connection of the components, the way and the basic idea are in part one .

i just want to show here the new idea and how it works :)

## Step 1: Send Part.

the sending part has the same idea of the old method, but here it send only the numbers 1\0. it get the char to be sent through the serial monitor using serial.read then it turn it into ones and zeros.

NOW HOW TO DO SO.... when i did the project I was just a begginer, i had to think with the methods I learned in digital class. I came up with this way to send data!

and the full code is included in the attachments

```<p>s_char = Serial.read(); //receive num from serial to resend<br>    s_int = s_char;</p><p> s_word += s_char; //s_word is a String type to store the sent word. fot testing things
while (digit < 8)
{ s_BIN[digit] = s_int % 2; // store the bit in an array
s_int = s_int / 2;
digit++;
}//this method is given in digital classes, to transfer decimal to binary
for (int i = 0; i < 8; i++) // now here send the bit using laser
{ if (s_BIN[i] == 0) {
digitalWrite(3, HIGH);
delay(100);  //the specified time for 0
digitalWrite(3, LOW);
delay(100);
}
if (s_BIN[i] == 1) {
digitalWrite(3, HIGH);
delay(200);
digitalWrite(3, LOW);
delay(200);
}

</p>```