36 lines
733 B
C++
36 lines
733 B
C++
const int START_LED = 2;
|
|
const int END_LED = 8;
|
|
const float DELAY = .3 * 1000;
|
|
|
|
|
|
void setup() {
|
|
Serial.begin(9600);
|
|
// put your setup code here, to run once:
|
|
for (int i = START_LED; i <= END_LED; i++) {
|
|
pinMode(i, OUTPUT);
|
|
digitalWrite(i, LOW);
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
for (int i = 0; i < 128; i++) {
|
|
int num = i;
|
|
Serial.print(i);
|
|
Serial.print(" ");
|
|
for (int j = 6; j >= 0; j--) {
|
|
if (num - pow(2,j) >= 0) {
|
|
digitalWrite(START_LED + j, HIGH);
|
|
Serial.print("1");
|
|
num -= pow(2,j);
|
|
} else {
|
|
Serial.print("0");
|
|
digitalWrite(START_LED + j, LOW);
|
|
}
|
|
}
|
|
Serial.println();
|
|
delay(DELAY);
|
|
}
|
|
|
|
}
|