Go Down

Topic: button or contact mic triggers series of events (Read 1 time) previous topic - next topic

rel

hello,

I've been working on a project using motors getting triggered in patterns by the arduino.  I've been using them for a sound installation, but now am interested in building a portable unit that both powers the motors and has a button or contact mic that will trigger the motors to display a series of patterns.  As far as the powering issues I think I have it under control, I've looked at the button tutorial, but that seems like it would basically turn on and off displaying the patterns when they would turn on--however many motors it was attached too.  I'm wondering if there is a tutorial or a thread I'm not finding that would allow the button to act more as a trigger to display say one of say 50 different events, each time I hit it displaying another pattern in random for example, completing it sequence and then turning off.  I'm wondering if it would be wired in a different place or if this would work based on the 'button' tutorial and would simply be  a coding issue!

thanks--

PaulS

Quote
if this would work based on the 'button' tutorial and would simply be  a coding issue!


Quote
the button to act more as a trigger to display say one of say 50 different events, each time I hit it displaying another pattern in random for example, completing it sequence and then turning off.

This really looks like a simple coding issue.

Each time the button is pressed, you generate a random number, and call the nth function in an array of function pointers.

Code: [Select]
void *funcPtrs[] = {doThis, doThat, doSomethingUseful, doSomethingUseless};

void doThis()
{
}

void doThat()
{
}

void doSomethingUseful()
{
}

void doSomethingUseless()
{
}


Each function does something to completion, then returns.
The art of getting good answers lies in asking good questions.

Go Up