Project help me please .. Triggered programmable sequence

Hi

I’m stuck and can’t find info on how to do this.

What i need to happen.

I have two optical sensors on a rotory set up. These need to give the 8 relays an open and close signal but they also need to be able to step the sequnce forwards and backwards.

The sequence for the relays need to be programmable and on a loop. The sequence may be up to 3000 or more steps long.

I have worked out the long sequence bit but it glitches at the end/begining of the loop. It give a random high on pin 8.

Now i am stuck. i have tried a few thing for the optical sensors to give the high and low for the relay but i dont understand what in doing.

This is what i have got so fare.

int i;
int relayPin = 2;

void setup() {
for ( relayPin = 2; relayPin < 10; relayPin++)
{pinMode(relayPin,OUTPUT); // set up relay pins 2-9 for output

}}

void loop() {

int pickArray [100] = {2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9
,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,
2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9,8,
7,6,5,4,3,2,3,4,5,6,};

int i;
for(i = 0; i<=100; i++){

digitalWrite (pickArray*, HIGH);*

  • delay (500);*

_ digitalWrite (pickArray , LOW);_

* delay (200);*

* }*
* }*

:o :o :o :o

These need to give the 8 relays an open and close signal

You really need to elaborate on this. When should the relays be turned on? When should they be turned off? Are all 8 to be turned on at the same time? Off at the same time?

but they also need to be able to step the sequnce forwards and backwards.

"the sequence" is a concept that exists solely in your mind.

int pickArray [100] = {2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9
                               ,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,
                               2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9,8,
                               7,6,5,4,3,2,3,4,5,6,};

Why do you need to piss away memory using an int array to hold byte values?

Does your code REALLY look like that?

Ok
The machine it's for uses punch cards to insert data. Punch card are made of plastic and where there is a hole it triggers 1 of 8 solenoids.
The solenoid need to be powered at the correct time in the machines rotation. When the machine is in reverse the punch cards go backwards too. The punch cards can have 1000s of of holes so the sequence loop can be big.

The idea is to replace the cards with the arduino.

The plan is to attach 2 optical sensors to the machine that will read the rotation position from two slotted disk. This will give the solenoid timing and direction of the machine.
Run the sequence from the arduino to 8 relays for the solenoids.

Problem 1:

How to get large sequences of numbers in to the arduino. The serial port would only let me read about 70 numbers. So i used an array. I have tested it to 1000 numbers so fare. but it triggers pin 8 at the end of a loop.

Problem 2:

How to get the optical sensors to move through the sequence one at a time forwards and bacwards.

Problem 3:

How to get the optical sensors to trigger the relays correctly.

Any tips or do i have to spend hours punching hole in plastic sheets (:

PaulS:
You really need to elaborate on this. When should the relays be turned on? When should they be turned off? Are all 8 to be turned on at the same time? Off at the same time?
"the sequence" is a concept that exists solely in your mind.

int pickArray [100] = {2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9

,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,
                              2,3,4,5,6,7,8,9,9,8,7,6,5,4,3,2,3,4,5,6,2,3,4,5,6,7,8,9,9,8,
                              7,6,5,4,3,2,3,4,5,6,};



Why do you need to piss away memory using an int array to hold byte values?

Does your code REALLY look like that?

How would you store a number sequence that could be 1000s of number for one loop? This sequence needs to be in this format. The number sequence can be copied strait from my design program so i dont even have to write it. Each number controles a relay one at a time. I need this number sequence to run forwards and backwards and the relay triggered at the right time for the right amount of time.

How would you store a number sequence that could be 1000s of number for one loop?

On a mass storage device.

How would you store a number sequence that could be 1000s of number for one loop?

Regardless of WHERE you store it (and AWOL is right), using the proper size container is always a good idea. Use the smallest container type that you can.

I need this number sequence to run forwards and backwards and the relay triggered at the right time for the right amount of time.

I really have no idea what you mean by “number sequence to run forwards and backwards”. You have some index into the array for the current event, whatever that means. You can increment the index or you can decrement the index. Makes no difference to me. Or to the Arduino.