/**
  ATtiny85 Menora for Hanukkah with Charlieplexing.

  Learn more about Charlieplexing: https://goodarduinocode.com/guides/charlieplexing

  Copyright (C) 2020, Uri Shaked
*/

#define BUTTON_PIN PB3

// LEDs are connected to PB0, PB1, PB2, and PB4, in Charlieplexing configuration.
// See diagram.json for more information about the actual connections.
byte LEDS[][2] = {
  {PB0, PB1},
  {PB1, PB0},
  {PB0, PB2},
  {PB2, PB0},
  {PB2, PB1},
  {PB4, PB0},
  {PB4, PB1},
  {PB4, PB2},
  {PB1, PB2},
};

void lightCandle(int index) {
  pinMode(PB0, INPUT);
  pinMode(PB1, INPUT);
  pinMode(PB2, INPUT);
  pinMode(PB4, INPUT);
  pinMode(LEDS[index][0], OUTPUT);
  pinMode(LEDS[index][1], OUTPUT);
  digitalWrite(LEDS[index][0], LOW);
  digitalWrite(LEDS[index][1], HIGH);
}

void setup() {
  pinMode(PB3, INPUT_PULLUP);
}

int candle = 0;
void loop() {
  if (digitalRead(PB3) == LOW) {
    candle = (candle + 1) % 8;
    delay(200);
  }
  lightCandle(8);
  for (int i = 0; i <= candle; i++) {
    lightCandle(i);
  }
}
ATTINY8520PU
tiny:PB5
tiny:PB3
tiny:PB4
tiny:GND
tiny:PB0
tiny:PB1
tiny:PB2
tiny:VCC
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
led5:A
led5:C
led6:A
led6:C
led7:A
led7:C
led8:A
led8:C
led9:A
led9:C
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r