Thanks for the input.
I cleaned up the code accordingly (a bit)
See below.
I removed the PULLUP arguement,
Changed from pin 1
The confusion with the Pullup/pulldown is because it was written for pulldown,
but I want to use a pullup button.
Didn't care about the const byte cause I have enough memory.
When I remove the brackets as you mentioned the code starts at the first line of action already which is not desired.
Here it is:
int Button = 2; // button
int valve = 3; // valve
int motorcw = 5; // Motor CW
int motorccw = 6; // Motor CCW
int feed = 9; // feed solenoid
void setup() {
pinMode(Button, INPUT);
pinMode(valve, OUTPUT);
pinMode(motorcw, OUTPUT);
pinMode(motorccw, OUTPUT);
pinMode(feed, OUTPUT);
pinMode(Button, INPUT);
}
void loop() {
while(digitalRead(Button) == 0){ // wait until button is pushed
}
setColor(255, 0, 0, 0); // activate valve
delay(250); // valve opening time
setColor(0, 255, 0, 255); // motor CW
delay(160); // motor travel time
setColor(0, 0, 0, 0); // loading
delay(100); // loading time
setColor(0, 0, 255, 255); // motor CCW
delay(160); // motor travel time
setColor(0, 0, 0, 0); // done
delay(0); // rate of production
}
void setColor(int redValue, int greenValue, int blueValue, int orangeValue) {
analogWrite(valve, redValue);
analogWrite(motorcw, greenValue);
analogWrite(motorccw, blueValue);
analogWrite(feed, orangeValue);
}