sequence memory step recording, where to start

so i have this project that I'm working on, and as part of it I'm looking for an arduino to record some button presses. 10 steps to the sequence. 1 button forwards the sequences step, 1 button turns the step it is on high, 1 button turns the step it is on low. and when it loops around it just remembers which of those 10 steps are high or low. and that sends a high or low out of an output according to the sequence.

regarding using an arduino to do something like this i havent ever done before, and i wouldn't know where to start. my arduino skills usually are limited to not remember things. so this is strange for me

the most frustrating thing is its probably super easy!

any help would be greatly appreciated

Do you need to remember the sequence after the power is turned off and turned on again? (Maybe weeks later.)

Then you need to use the EEPROM. Strat reading the documentation and try a few of the examples for that.

zibrazibrazibra: would be greatly appreciated

I'd assign each button a letter representing its function like 'F' (forward), 'H' (HIGH) and 'L (LOW).

In case timing is not relevant, store the pressed buttons in a char array (nullterminated string). In case you need to store time and button for further usage, store millis() values and chars in an array of strruct, where the struct keeps a time as unsigned long and a char.

MorganS: Do you need to remember the sequence after the power is turned off and turned on again? (Maybe weeks later.)

Then you need to use the EEPROM. Strat reading the documentation and try a few of the examples for that.

for right now morgan I'm not going to worry about that, the array is so short

Would it work if you had an array of characters like this

char stepList[] = "HHLHLLLHH";

If so it would be straightforward to write a piece of code to save each successive button press into the next array element until the array is full or a "finish" button is pressed.

...R

thanks jurs ill look into char array

yeah i suppose it makes sense. ill put this into motion and see what i get.

the whole thing doesn't ever need to finish though, just going round and round and round, and you can just adjust from high to low or low to high when your on that step.

ok so for a second I'm looking into it can i just do it like this

STEPS[] {0,0,0,0,0,0,0,0,0,0}

then in the code when the forward button presses it goes to the next (string? i want to say string? that might be the wrong one) and just have it so high just sets that number to 1, and low sets it to zero.

then the out pin goes high when the string is one?

does that make sense? just stumbling through it now.

Yes. You could have an array of bytes with each one either a 1 or a 0.

byte STEPS[] = {0,0,0,0,0,0,0,0,0,0};

If you are going to store 1s and 0s it would make more sense to use bytes (numbers) rather than characters because you would have to convert the characters to numbers before using them.

It is actually possible to store 8 steps (1s or 0s) in a single byte but that is probably too complex for now.

...R

WOO. i got it down after a few hours at it along with a couple of other functions.

so the EEPROM talk got me thinking about being able to simply remember the last array states before shutdown. how hard would that be to implement?

The difficult bit is detecting shut down when just the power is removed. This requires some electronics. You could write the array to EEPROM every time it is changed but there is a limit of 10,000 EEPROM writes for any one address so it could limit the time that this could operate. In practice his limit is a bit higher but it is finite.

thanks grumpy mike. yes I've figured so.

this is really coming on, and really making a lot of things make sense. learnt more in 5 days of just attacking it than i must have in 3 or so years of thumbling through arduino

how would i address a bit array to EEPROM if i was to hold a button for say 5 seconds? its an array or about 40x8 1 and 0's pretty tiny!!!!!

1 more question! how the hell do i write this into a single line? i just can't work it out?

  Sequence[Channel+BankClear][1] = 0;
  Sequence[Channel+BankClear][2] = 0;
  Sequence[Channel+BankClear][3] = 0;
  Sequence[Channel+BankClear][4] = 0;
  Sequence[Channel+BankClear][5] = 0;
  Sequence[Channel+BankClear][6] = 0;
  Sequence[Channel+BankClear][7] = 0;
  Sequence[Channel+BankClear][8] = 0;
  Sequence[Channel+BankClear][9] = 0;
  Sequence[Channel+BankClear][10] = 0;
  Sequence[Channel+BankClear][11] = 0;
  Sequence[Channel+BankClear][12] = 0;
  Sequence[Channel+BankClear][13] = 0;
  Sequence[Channel+BankClear][14] = 0;
  Sequence[Channel+BankClear][15] = 0;
  Sequence[Channel+BankClear][16] = 0;
  Sequence[Channel+BankClear][17] = 0;
  Sequence[Channel+BankClear][18] = 0;
  Sequence[Channel+BankClear][19] = 0;
  Sequence[Channel+BankClear][20] = 0;
  Sequence[Channel+BankClear][21] = 0;
  Sequence[Channel+BankClear][22] = 0;
  Sequence[Channel+BankClear][23] = 0;
  Sequence[Channel+BankClear][24] = 0;
  Sequence[Channel+BankClear][25] = 0;
  Sequence[Channel+BankClear][26] = 0;
  Sequence[Channel+BankClear][27] = 0;
  Sequence[Channel+BankClear][28] = 0;
  Sequence[Channel+BankClear][29] = 0;
  Sequence[Channel+BankClear][30] = 0;
  Sequence[Channel+BankClear][31] = 0;
  Sequence[Channel+BankClear][32] = 0;
  Sequence[Channel+BankClear][33] = 0;
  Sequence[Channel+BankClear][34] = 0;

cant for the life of me work that one out

how would i address a bit array to EEPROM if i was to hold a button for say 5 seconds?

By address do you mean store a bit array in EEPROM?

You use for loops to access each byte of your array and store in the EEPROM using the EEPROM.write(a, v) where a is the address and v is the value you want to store in it.

write this into a single line?

for(int i = 1; i<35; i++){
Sequence[Channel+BankClear][i] = 0;
}