# Laser Data Transfer, Part2- Binary Transmitting.

2,523

19

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 :)

### Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

## 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>```

in the receiver part the same method is used, but here to decode the result and get the char sent. after the char is done receiving it the char is displayed on the LCD.

and the final code is attached and it contain some notes :) .

this method has some problems, it's slow and requiers mathmatics operations that make it slower and costy on the arduino uC .... HOWEVER, it works fine some how .

the next part; and the final progress i made in this project so far ; is much better and faster. I Learned to use timers and Bitwise math, and this could push the project to limits :) i will post it next time :) .

hope you like it, thanks for reading .

## Recommendations

• ### Internet of Things Class

22,733 Enrolled