#define START_LED 2
#define LED_COUNT 8
uint8_t count = 0;
void setup() {
Serial.begin(115200);
for (uint8_t led = START_LED; led < LED_COUNT + START_LED; led++) {
pinMode(led, OUTPUT);
}
}
void loop() {
setLEDsToCount();
Serial.print("DEC: ");
Serial.print(count,DEC);
Serial.print(" BIN: 0b");
Serial.print(count,BIN);
Serial.print(" HEX: 0x");
Serial.println(count,HEX);
delay(1000);
count++;
}
void setLEDsToCount() {
for (uint8_t led = START_LED; led < LED_COUNT + START_LED; led++) {
if ((count >> led - START_LED) & 0x1) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
}
}