Introduction: Step by Step and All Clear, How to Transmitting Data Over LASER.part1.
This project I was asked to do for learning by my instructor Mohannad Rawashdeh, I did it and found it interesting and further challenging.As I learned much from it, i thought it will be good to share it!
after this done and because of my interest of transmitting data and analyzing codes, with time I learned some new stuff so I could upgrade the project, And this is the first part of it. hope you see it easy and much helpful.
in this part I gonna show how to transmit some specified data you want! like numbers from 0 to 9, I gonna transfer data from one arduino using laser-pointer light, to another arduino that receive the light with LDR or photo diode and then recover the data and display it on an LCD screen.
in this part I will show how it works and how to deal with laser module and LDR to do this. and I suppose that you already know how to work with LCD cause this actually needs special instructable.
to get started you need these:
* two arduinos one is transmitter and other receiver and you free to pick your board, any board should work. I used an uno board and mega board.
*Laser module ( i got it from genotronex store!)
*LDR (or photo diode)
*resistor 5k (I used two parallel 10k)
* jumpers and two breadboard (for learning and practice purposes, one should be enough)
*USB cables and arduino IDE installed on computer!
***This instructable is available in arabic on genotronex bolg.
UPDATE ::
this is the part 2.... laser binary transfer.
Step 1: Methodology.
the general principle of data transmitting, is to adjust the sender and receiver to some protocol or some way to communicate. like adjusting it send 1/0 in serial communication or pattern of lights on/off in Morse code.
here we gonna use time!
simply we do that by specify a time for each char or num we want to transmit, then send high signal on some pin for the specified time, the high signal turn ladder module on/off.
in the receiver part, we set the arduino receive the signal and calculate the time of the high signal received, selecting the char or num by pre telling the arduino the specified time for each char that should be received.
and that is much funny and interesting!
Step 2: Setting Up the Sender Part!
in my project I adjusted the sender and receiver to some specific times. I set 100ms for '0' , 200 for '1' and so on.
this done with simply using delay function and if stamens.
the project receive some number from the serial monitor and send it as laser signal accordingly.
the laser module is much easy to use it like the led it has anode and cathode and include resistor on the module too just attach the sender pin to 's' pin on the laser module and the '-' to the ground.
and here is the code that contain some notes! :)
Attachments
Step 3: Receiver Part
the receiver part needs some work put still much easy and simple! I had some problems at first but then I could found my HERO function due to my instructor advice.(I was just starting learning arduino then).
the problem was, how to measure the time! there is two ways.... millis() and pulsIn() function. I used pulsIn(), it is too easy to work with and good accurate and has good options.
this function as note in the reference measure the width of pulse! it returns the time that the pin have in some state in microseconds and then then we use this time to select the received value.
the pin state is changed by LDR sensor that change its resistance by the much of light applied to it, connect it with 5k resistor and read from the node joining them, when the laser hit the LDR its resistance changed enough to change the pin state.
and here is the code.
Attachments
Step 4: One Extra Note on Receiver Side!
the pulse in function is much accurate really but for some reason it base some noise in the signal!(may be for laser trr or the LDR response speed!!) so it always return the value with some extra time!
such like if we send 5 means laser light up for 600ms, but the received value with pulsIn return something like 640ms! its clear that we must get red of the 40ms that appeared!
we can do this simply by the modulo mathematic operation (%) that give remainder val of the division on some number.
here we do 640%100 to get 40.
and then subtract the result from the value.
Step 5: The LCD Screen!
I suppose you know how to work with that! I just gonna show how to connect it to this project.
the pins are :
Rs ---> 12
En ---> 11
D4 ---> 5
D5 ---> 6
D6 ---> 7
D7 ---> 8
here the received data will be appear on the screen, and I sent some extra char that should clear the screen!
you can do some extra stuff like make a counter to move the curser to the second row when it receive 16 char or add any other sensors or output ways such buzzer! I just shown the main idea here :)
** the connection shown before in step 2
Step 6: Give It a Try!
let's send some data! try send 7. the laser should light up for 800ms. then the reciver measure the time and print the value on the LCD screen!
that is all here! next I should tell how to use the laser as simple serial transmitter.
hope you enjoyed this! and hope it was useful :)
good luck .