Still new to programing. I have a code that works perfect but is long and would like make it simple and easier to change if need be.
I have four values, I would like to take those and make them equal to a word or even something like 0100. So i can go like this
if (0100 == true) {
digitalWrite(ccwPin, LOW);}
this is what I have now that works
if ((oneValue == 0) && (twoValue == 1) && (threeValue == 0) && (fourValue == 0)) { // readings from digital inputs
digitalWrite(ccwPin, LOW);
}
Please post your entire sketch so we can grasp the context of the snippet you posted. The need is explained here:
I can tell you, in general what you propose is a bad idea, it makes anonymous the variables that are presently easily identifiable. Future maintenance is easier to perform on if statements like the one you posted, than on an obscure numerical code.
If there are too many of those 'if' statements, it's possible that your programming logic is inefficient or the approach is repetive and doesn't benefit from code factoring and indexed container features like arrays and structs that also can be used to avoid repetition.
So here is a loop that reads the inputs. I would like to assign a value(encoder) to each of the possible values.
I played with the byte shift << but I think that isn't what I'm looking for.
This code compiled but didn't work.