First of all let me compliment you on your English. It gave little indications you are not native speakers.
With proper supervision, a 10 terra watt rail gun would have been a fun project.
The best way to help you is to walk you through what I did.
I opened up the Arduino IDE (version 0022). Fom the main menu I selected:
File…Example…Basics…Blink
This opened a sample program that is ridiculously close to what you need.
In the “setup” function (only called once on power up or reboot), I added the definitions of pins 3,4,5,6,7,8,9 as outputs. I also make the assumption that a high signal will turn on your MOSFET.
I changed the comment at the top.
Next I started to work on the loop function. Loop gets called over and over again. As soon as one iteration is completed, another is started. No need to code an infinite loop. Here I create the first sequence turning on and off the pin using digitalWrites and delays (in milliseconds) to pulse the pins in sequence. Once this was written, I needed a simple way to start a different sequence. I picked (among several different ways) to use a series of IF statements. At the conclusion of one IF I set the “Sequence” variable for the second. This way you could extend the sequences if you need to.
This program is not likely what you will need to get your project to work. The program compiles, but I have left in at least one logic “bug” that you should be able to find and solve simply.
It might be hepful to add an LED to each output pin as well as the MOSFET so that you can see what is happening.
Good luck!
/*
Ferro fluid test
*/
int sequence;
void setup() {
// initialize the digital pins as an output.
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
sequence = 1;
}
#define S1_ON 10
#define S1_OFF 10
#define S2_ON 5
#define S2_OFF 5
void loop() {
if (sequence == 1) {
digitalWrite(3, HIGH);
delay(S1_ON);
digitalWrite(3, LOW);
delay(S1_OFF);
digitalWrite(4, HIGH);
delay(S1_ON);
digitalWrite(4, LOW);
delay(S1_OFF);
digitalWrite(5, HIGH);
delay(S1_ON);
digitalWrite(5, LOW);
delay(S1_OFF);
digitalWrite(6, HIGH);
delay(S1_ON);
digitalWrite(6, LOW);
delay(S1_OFF);
digitalWrite(7, HIGH);
delay(S1_ON);
digitalWrite(7, LOW);
delay(S1_OFF);
digitalWrite(8, HIGH);
delay(S1_ON);
digitalWrite(8, LOW);
delay(S1_OFF);
digitalWrite(9, HIGH);
delay(S1_ON);
digitalWrite(9, LOW);
delay(S1_OFF);
sequence = 2;
} else if (sequence == 2) {
digitalWrite(3, HIGH);
delay(S2_ON);
digitalWrite(3, LOW);
delay(S2_OFF);
digitalWrite(4, HIGH);
delay(S2_ON);
digitalWrite(4, LOW);
delay(S2_OFF);
digitalWrite(5, HIGH);
delay(S2_ON);
digitalWrite(5, LOW);
delay(S2_OFF);
digitalWrite(6, HIGH);
delay(S2_ON);
digitalWrite(6, LOW);
delay(S2_OFF);
digitalWrite(7, HIGH);
delay(S2_ON);
digitalWrite(7, LOW);
delay(S2_OFF);
digitalWrite(8, HIGH);
delay(S2_ON);
digitalWrite(8, LOW);
delay(S2_OFF);
digitalWrite(9, HIGH);
delay(S2_ON);
digitalWrite(9, LOW);
delay(S2_OFF);
}
}