int timer = 1000;
int pinCounter = 0;
int state;
#define DEBUG 0 // SET TO 0 OUT TO REMOVE TRACES
#if DEBUG
#define D_SerialBegin(...) Serial.begin(__VA_ARGS__);
#define D_print(...) Serial.print(__VA_ARGS__)
#define D_write(...) Serial.write(__VA_ARGS__)
#define D_println(...) Serial.println(__VA_ARGS__)
#else
#define D_SerialBegin(...)
#define D_print(...)
#define D_write(...)
#define D_println(...)
#endif
void setup() {
// put your setup code here, to run once:
for (int thisPin = 2; thisPin < 7; thisPin++) {
pinMode(thisPin, OUTPUT);
}
D_SerialBegin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for (int counter = 0; counter <32; counter ++) {
D_print("counter = ");
D_println(counter);
for (int pinCounter = 2; pinCounter < 7; pinCounter++) {
int bitValue = round(pow(2,(pinCounter - 1)) * 10) / 10.0;
int modCheckValue = round((pow(2,(pinCounter - 2)) - 1) * 10) / 10.0;
D_print("bitValue = ");
D_println(bitValue);
D_print("modCheckValue = ");
D_println(modCheckValue);
int counterBitValue = counter % bitValue;
D_print("counterBitValue = ");
D_println(counterBitValue);
if (counterBitValue > modCheckValue) {
state = 1;
} else {
state = 0;
}
D_print("pinCounter = ");
D_print(pinCounter);
D_print(", state = ");
D_println(state);
digitalWrite(pinCounter,state);
}
delay(timer);
}
}