Pages: [1]   Go Down
Author Topic: Breaking a laser sensor.  (Read 2178 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to make a circuit with the arduino that basically tells me when someone has tripped a laser in my room.

I know I should use a photoresistor and a laser. Now I wanted to do  this and post it on twitter whenever somone passed the laser but now I want the computer to take a webcam picture and store it on my hard drive whenever someone passes the laser. Or even eaiser, just log what time the laser was tripped.

Anyone know how to at least log the time the laser was tripped?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17292
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Anyone know how to at least log the time the laser was tripped?

Sure, just wire up a real time clock chip (RTC) and that will allow you to read the time when the laser is tripped. You should break your project up into little parts, and build and test each section. Later you can combine it all together and add higher order functions like tweeting and such. First build the laser/detector circuit and write a simple sketch to light up the on-board pin 13 led when the laser path is broken.

Lefty

Logged

Sussex UK / CT USA
Offline Offline
Edison Member
*
Karma: 0
Posts: 1028
Forums forever
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The nuelectronics datalogging shield ($16 + P&P) will give you the SD card and the RTC....

http://sheepdogguides.com/arduino/ar3nd.htm
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But is there any way to do this clock timing with software? I don't want to buy extra parts.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But is there any way to do this clock timing with software?
Yes, but you'll have to manually reset the time every time you turn the Arduino on.
Logged

Per Arduino ad Astra

Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But is there any way to do this clock timing with software?
Yes, but you'll have to manually reset the time every time you turn the Arduino on.

thats no problem for me, show me this software!
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 205
Posts: 12844
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.google.com/search?q=arduino+time+library
http://www.arduino.cc/playground/Code/Time
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262783962
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


yes but.... I don't know how to use the time library and even though I have the time library I still need to be able to log the time somewhere .
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 610
Posts: 49016
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I don't want to buy extra parts.
Quote
I still need to be able to log the time somewhere .
Well, where do you expect to log this data?

You can follow the examples provided with the time library, and actually learn something, instead of just whining.

This is beginning to sound like homework that is late.
Logged

London, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Why not save the logging data to ram, and have a pushbutton to send the data to the serial monitor as and when required? Or let it transmit all the time.... This necessitates the connection of the arduino to a pc via usb running the ide though.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Given the fact that your computer is going to be on in order to take the picture from webcam, it seems only logical to power the circuit via the computer USB.

If you don't wish to purchase extra parts, I suggest the following:

Create and upload a sketch to the arduino, so the arduino sends a serial message to the computer every second of either "0", beam not broken, or "1" beam broken.

Then create a simple program in VB or something which reads the incoming serial data.

If incomingSerialData = "1" Then
   'Log time here using Now() function or similar
   'take picture, play an alarm sound etc etc.
 End If
Logged

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using millis that lasts for a few day and then overflows and the EEPROM that the Atmega used in the arduino, you only need to add an LDR and a little bit of code, maybe to even 40 lines and its done.
Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Given the fact that your computer is going to be on in order to take the picture from webcam, it seems only logical to power the circuit via the computer USB.

If you don't wish to purchase extra parts, I suggest the following:

Create and upload a sketch to the arduino, so the arduino sends a serial message to the computer every second of either "0", beam not broken, or "1" beam broken.

Then create a simple program in VB or something which reads the incoming serial data.

If incomingSerialData = "1" Then
   'Log time here using Now() function or similar
   'take picture, play an alarm sound etc etc.
 End If

ok with your advice I got the arduino to output a 1 every time a certain value of my photo resistor is breached and a 0 when it goes below that. So basically I got it to write a 1 and 0 now but I need more explanation about VB and coding it from there now.
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 23
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, download VB express 2010, if you haven't already.

Start a new project.

Stick a timer control onto the form.

Then double click the form to get into the code.

After one of the "End Sub" 's, copy and paste the following function, not forgetting to set the correct COM port you are using:

Code:
    Function ReceiveSerialData() As String
        ' Receive strings from a serial port.
        Dim returnStr As String = ""

        Using com As IO.Ports.SerialPort = _
                My.Computer.Ports.OpenSerialPort("com4")
            Dim Incoming As String = com.ReadLine()
            If Incoming Is Nothing Then
                MsgBox("No Data Captured.")
            Else
                returnStr &= Incoming & vbCrLf
            End If
        End Using

        Return returnStr

        MsgBox("Fail!")
    End Function

Then scroll all the way to the top of the code for the program, and paste the following:

Code:
Imports System.IO

That's the code to get the serial data.

Now go back to your form, and click the timer you placed earlier. Change the interval to 1000.

Double click the timer to get into the code for it.

Here is where you will enter the code to be executed each time 1 second passes.

So you'd want something like:

Code:
If receiveSerialData() = "1" Then
   'code here
End If

As I mentioned previously, the built-in Now() function is useful for getting the current date and time.

Logged

Offline Offline
Full Member
***
Karma: 0
Posts: 236
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, download VB express 2010, if you haven't already.

Start a new project.

Stick a timer control onto the form.

Then double click the form to get into the code.

After one of the "End Sub" 's, copy and paste the following function, not forgetting to set the correct COM port you are using:

Code:
    Function ReceiveSerialData() As String
        ' Receive strings from a serial port.
        Dim returnStr As String = ""

        Using com As IO.Ports.SerialPort = _
                My.Computer.Ports.OpenSerialPort("com4")
            Dim Incoming As String = com.ReadLine()
            If Incoming Is Nothing Then
                MsgBox("No Data Captured.")
            Else
                returnStr &= Incoming & vbCrLf
            End If
        End Using

        Return returnStr

        MsgBox("Fail!")
    End Function

Then scroll all the way to the top of the code for the program, and paste the following:

Code:
Imports System.IO

That's the code to get the serial data.

Now go back to your form, and click the timer you placed earlier. Change the interval to 1000.

Double click the timer to get into the code for it.

Here is where you will enter the code to be executed each time 1 second passes.

So you'd want something like:

Code:
If receiveSerialData() = "1" Then
   'code here
End If

As I mentioned previously, the built-in Now() function is useful for getting the current date and time.







Wow thanks for the help! I will try this when I get home
Logged

Pages: [1]   Go Up
Jump to: