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..