Thanks,
here's the code.
Works great so far.
But I just need it to start at a pushbutton and loop as long as the pushbutton is pressed.
But It always has to end at the last step (after releasing the pushbutton) otherwise my object gets stuck in the process.
int valve = 3; // valve
int motorcw = 5; // Motor CW
int motorccw = 6; // Motor CCW
int feed = 9; // feed solenoid
void setup() {
pinMode(valve, OUTPUT);
pinMode(motorcw, OUTPUT);
pinMode(motorccw, OUTPUT);
pinMode(feed, OUTPUT);
}
void loop() {
setColor(255, 0, 0, 0); // activate valve
delay(250); // valve opening time
setColor(0, 255, 0, 255); // motor CW
delay(200); // motor travel time
setColor(0, 0, 0, 0); // loading
delay(100); // loading time
setColor(0, 0, 255, 255); // motor CCW
delay(200); // motor travel time
setColor(0, 0, 0, 0); // done
delay(2000);
}
void setColor(int redValue, int greenValue, int blueValue, int orangeValue) {
analogWrite(valve, redValue);
analogWrite(motorcw, greenValue);
analogWrite(motorccw, blueValue);
analogWrite(feed, orangeValue);
}