// Define necessary pins
const int ledPin = 26;
const int ledPin2 = 0;
const int ledPin3 = 1;
void setup() {
// Initialize pins as outputs
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}
void loop() {
for (int i = 0; i < 8; i++) {
// Start sequence with all LEDs off
digitalWrite(ledPin, LOW);
digitalWrite(ledPin2, LOW);
digitalWrite(ledPin3, LOW);
Serial.println(i);
// Convert int to binary and then string
String b = String(i, BIN);
// Turn on LED 001
if (b.charAt(b.length() - 1) == '1') {
digitalWrite(ledPin, HIGH);
}
// Turn on LED 010
if (b.charAt(b.length() - 2) == '1') {
digitalWrite(ledPin2, HIGH);
}
// Turn on LED 100
if (b.charAt(b.length() - 3) == '1') {
digitalWrite(ledPin3, HIGH);
}
delay(1000);
}
}