I'm currently making a project on arduino nano of a laser tripwire, but i wanted to add some new things to make it unique. Basically i'm making a laser pen blink with a random generated frequency and by now it's all good.
The problem comes when the sensor (photodiod or even a solar cell), reading the signal sended by the laser. By personal expirience working with raw Atmega328p i can read the signal and analise the times it's HIGH AND LOW, but cannot yet figure out the time that it was on each state.
For laser signal i used a timer in a certain way that it would start to count at random interval (TCNT).
I actually made it. I used a single toggle bit that would toggle each time the laser would change state, in that way the sensor would know when he would receive and not receive the signal.
i can read the signal and analise the times it's HIGH AND LOW, but cannot yet figure out the time that it was on each state.
What?
NOTE - It takes a special driver to "pulse" laser diode and send data (like you do with an LED in an IR remote control). So, don't try to pulse it too fast... And, you'll need a short delay between the time that you "write" to the laser and the time you read the photodiode.
But, it should be simple enough to turn the laser on and then check to see if you're reading high or low (depending if the circuit inverts the data) and turn the laser off and do the same thing.
And if you can do that, it shouldn't be too hard to put that in a loop while "blinking" the laser, and when that works it shouldn't be to hard to add some randomized timing to the blink.
DVDdoug:
But, it should be simple enough to turn the laser on and then check to see if you're reading high or low (depending if the circuit inverts the data) and turn the laser off and do the same thing.
And if you can do that, it shouldn't be too hard to put that in a loop while "blinking" the laser, and when that works it shouldn't be to hard to add some randomized timing to the blink.
I actually did that the problem was resigned in the delay so the sensor could capture the value input and analise it in the short spawn of time.
TLDR; i just shortnet the code so it would be faster and had the time to analise propertly the input.