Go Down

Topic: LED Lighting project, Need Help Urgently! (Read 508 times) previous topic - next topic

Jakdrinnan

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


fungus

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

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

CrossRoads

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: [Select]

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?
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up