element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
    About the element14 Community
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      •  Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum Help making basic laser trip wire program fit my needs..
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 4 replies
  • Subscribers 417 subscribers
  • Views 568 views
  • Users 0 members are here
Related

Help making basic laser trip wire program fit my needs..

e14 Contributor
e14 Contributor over 13 years ago

Hello friends. Well I've been toying with my new Uno and I think I have the basics down but a few things I need it to do are still beyond me. I've read two books so far but the examples they give seem to be more information driven and not sensors based. I have a basic laser trip wire with this sketch and it works like it is supposed to..

 

 

void setup(){

pinMode(4, OUTPUT);          // Laser

pinMode(13, OUTPUT);        // LED

}

 

void loop(){

digitalWrite(4, HIGH);           // Turn on laser

if(analogRead(0) < 750){       // Read sensor

digitalWrite(13, HIGH);         // Turn on LED

}else{

digitalWrite(13, LOW);         // Turn off LED

}

}

 

 

 

So like I said this works fine for the basics but I need to add a few things.

 

1. A timer- I need to only run this program once every 30 minutes for 2 minutes. Would I need an RTC because I believe 30 minutes is too long for the built in Timer1?

 

2. I need to incorporate either a http://www.seeedstudio.com/wiki/Grove_-_Ultrasonic_Ranger or a http://www.seeedstudio.com/wiki/Grove_-_IR_Distance_Interrupt that runs with the  http://www.seeedstudio.com/wiki/Grove_-_Light_Sensor or before the program AND after a minute of the program running. The reason being is the OUTPUT that is triggered by the break in the laser will be a relay controlled motor so I need to make sure the motor doesnt turn on when I am at max height or the laser or sensor malfunction and burn up my motor. I understand I can use a double IF but from what I have read I can't have 2 sensors running at the same time so I need to know how to do them asimultaneously where the program shuts down if the range < 8in at anytime during the 2min on time or run the range finder first and IF the range is > 8'' run the laser wire for 1min and then loop back around and run it one more time. If the range < 8'' do nothing.

 

3. The laser I'm using is rather strong so I would like to blink an LED for 10secs before the laser turns on so I am not too close.

 

If anyone out there can help with any of this I would really appreciate it because my brain is going nuts trying to figure this out. I hope my first post makes sense..

  • Sign in to reply
  • Cancel
Parents
  • e14 Contributor
    0 e14 Contributor over 13 years ago

    Im not sure if this will help you, but I am using this for timing on my project.

     

    http://www.pjrc.com/teensy/td_libs_TimeAlarms.html

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mcb1
    0 mcb1 over 13 years ago in reply to e14 Contributor

    Dustin

     

    Good explanation.

     

    You certainly can run the sensors together.

    It might help to think of it as a time sharing exercise, where you fire the laser, check the response.

    If the responses is move, then check the height, move x,

    laser check to be sure you're clear (if not then, check height, move x and repeat).

    If check height is too close to the ceiling then, turn off the light and make noises, etc.

     

     

    You are approaching the sketch the right way, by trying to write it yourself, and learning in the process.

    There are many requests here to just provide the sketch, which imo is not the best method and doesn't achieve the right outcome.

     

    Keep us posted.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • mcb1
    0 mcb1 over 13 years ago in reply to e14 Contributor

    Dustin

     

    Good explanation.

     

    You certainly can run the sensors together.

    It might help to think of it as a time sharing exercise, where you fire the laser, check the response.

    If the responses is move, then check the height, move x,

    laser check to be sure you're clear (if not then, check height, move x and repeat).

    If check height is too close to the ceiling then, turn off the light and make noises, etc.

     

     

    You are approaching the sketch the right way, by trying to write it yourself, and learning in the process.

    There are many requests here to just provide the sketch, which imo is not the best method and doesn't achieve the right outcome.

     

    Keep us posted.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube