Pages: [1]   Go Down
Author Topic: LED Lighting project, Need Help Urgently!  (Read 476 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am quite new to Arduino programming, but have a live project that needs to be installed next week with a completely working system. Fortunately I dont think what i need to do is terribly complicated, just slightly beyond my reach at the moment.

Basically I will be using and Arduino Mega to control a relay board connected to 10 different LED strips. I have a megnetic hall effect sensor which is connected to one of the Megas digital pins. Every other time the sensor is triggered, I need one of the LED strips to turn off. I also need a timer to start after the first trigger for 30 seconds, after which all the lights that are currently will turn back on and the system can start again.

I hope i have made a clear explanation of what I am looking for. I do have a working model that I made through the Grasshopper plugin Firefly, but the code wont compile properly and doesnt work on the board.

Using the Arduino IDE I can turn off all the lights in order each after a certain amount of state changes, but my major problem that i cant seem to find a solution for the timer and reset 30 seconds after the first state change.

Any help pointing me in the right direction would be much a appreciated, and anyone willing to help out with some code will be reimbursed for their time accordingly.

As I say, I need this to be up and running asap for an installation next week. Need a working model hopefully by Tuesday.

Many thanks

Jak Drinnan
Nicholas Alexander, Creative Construction

Logged

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 150
Posts: 5744
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I might be able to help...send me a PM.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 549
Posts: 27425
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I suggest you use millis() to watch the elapsed time.
Capture the millis() when you do the first transition, and every pass thru loop captures it again until the time has passed that  you reset/restart.
I often set a flag to indicate that an action is in progress, and use that and a time comparison to make a decision:
Code:
void loop(){
if ((triggerevent occurred) & (event_running == 0)){
event_running = 1;
starttimemillis = millis();
// start event action
}

currentmillis = millis();
if ((event_running == 1) &( (currentmillis - eventstartmillis)>=interval)){
event_running  = 0;
// other stop event action
}
} // end loop

This is the basis of "blink without delay" that is referenced often.  Make sense?
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

Pages: [1]   Go Up
Jump to: