Go Down

Topic: Audio fx trigger (Read 2274 times) previous topic - next topic

Sarah1234

Hi I tried putting the code in between the tags but it won't let me .

marine_hm

In your arduino sketch  press Ctrl and A at the same time, then Ctrl C.
Once you've done that press reply in this forum.
Just above the area you type your message is a small toolbar.  The first tool is the insert code tag </>
Press that and place your cursor between the code tags... Press Ctrl V

Grumpy_Mike

Is it saying your code is too big?
If so use reply not the quick reply and attach it, like it tells you in the instructions about how to use this forum sticky post.

Sarah1234

Hi my problem is that I can't get my PC on the net at the mo waiting for BT so I have to communicate through this iPad which doesn't have my code sketch on it but will try to get a friend to do lt.

Sarah1234

I Finally have some BB, here is the sketch courtesy of Mark T.
Code: [Select]

#define IDLE 0
#define MOVING 1
#define DELAYING 2

#define DISTANCE  ???  // steps to move

#define button_pin ??

unsigned long when = 0L ;

byte state = IDLE ;

AccelStepper stepper (????) ;  // pins and mode

void setup ()
{
  stepper.setSpeed (???) ;   // top speed, steps/sec
  stepper.setAcceleration (???) ; // top acceleration steps/sec/sec
}

void loop ()
{
  stepper.run () ;   // progress the stepper.  This must be called regularly and often

  // statemachine to progress the states
  switch (state)
  {
  case IDLE:
    if (digitalRead (button_pin) == LOW)
    {
      stepper.moveTo (DISTANCE) ;   // AccelStepper handles the rest, so long as you call run() often
      state = MOVING ;
    }
    break ;
  case MOVING:
    if (stepper.currentPosition () == DISTANCE)
    {
      state = DELAYING ;
      when = millis () ;
    }
    break ;
  case DELAYING:
    if (millis () - when >= 10000)
    {
      stepper.moveTo (0) ;   // start moving back
      state = IDLE ;
    }
  }
}

Go Up