Board received, just shot @ebinkerd a mail. Will be posting some stuff soon!
const int CR = 2; // cylinder reference
const int CP = 3; // cylinder position
const int cyl1 = 4; //Cylinder 1
const int cyl2 = 5; //Cylinder 2
const int cyl3 = 6; //Cylinder 3
const int cyl4 = 7; //Cylinder 4
int buttonPushCounter = 0; // counts the amount of time the cylinder reference changes from high to low
int crButtonState = 0; // CR current state
int crLastButtonState = 0; // CR last button state
int buttonPushCounter1 = 0; // counts the ammount of times the cylinder position changes from high to low
int cpButtonState = 0; // CP current state
int cpLastButtonState = 0; // CP last button state
void setup() {
// put your setup code here, to run once:
pinMode(CR, INPUT); // Sets CR pin as Input
pinMode(CP, INPUT); // Sets CP pin as Input
pinMode(cyl1, OUTPUT); // Sets pin as output
pinMode(cyl2, OUTPUT); // Sets pin as output
pinMode(cyl3, OUTPUT); // Sets pin as output
pinMode(cyl4, OUTPUT); // Sets pin as output
}
void loop() {
crButtonState = digitalRead(CR);
cpButtonState = digitalRead(CP);
// compares the current button state to the last state, if different, push counter is incremented
if (crButtonState != crLastButtonState){
if (crButtonState == HIGH)(buttonPushCounter = buttonPushCounter + 1);
}// sets cyl output based on "buttonPushCounter" current value
if (buttonPushCounter == 1) digitalWrite(cyl1, HIGH);
else digitalWrite(cyl1, LOW);
if (buttonPushCounter == 2) digitalWrite(cyl2, HIGH);
else digitalWrite(cyl2, LOW);
if (buttonPushCounter == 3) digitalWrite(cyl3, HIGH);
else digitalWrite(cyl3, LOW);
if (buttonPushCounter == 4) digitalWrite(cyl4, HIGH);
else digitalWrite(cyl4, LOW);
// resets buttonPushCounter to 0
if (buttonPushCounter == 5) (buttonPushCounter = 0);
// If CR is high then CP start counting to 8 then resets buttonPushCounter1 and buttonPushCounter to 0
if (crButtonState == HIGH){
if (cpButtonState != cpLastButtonState){
if (crButtonState == HIGH)(buttonPushCounter1 = buttonPushCounter1 + 1);
}
if (buttonPushCounter1 == 8)(buttonPushCounter == 0);
}
}
void setup() {
// put your setup code here, to run once:
pinMode(CR, INPUT); // Sets CR pin as Input
pinMode(CP, INPUT); // Sets CP pin as Input
pinMode(cyl1, OUTPUT); // Sets pin as output
pinMode(cyl2, OUTPUT); // Sets pin as output
pinMode(cyl3, OUTPUT); // Sets pin as output
pinMode(cyl4, OUTPUT); // Sets pin as output
}
void setup() {
DDRD = DDRD | B11110000;
}