ATtiny85 Christmas Bauble


Figure 1 - Working Bauble

First use for the very tiny and very cool ATtiny85 microprocessor; the Christmas Bauble.

My first go at this shows my limited fabrication skills!  But it functions well & looks great in the dark.  The LEDs flash & chase around in various styles.

The only difficulty was soldering the button cell battery holder to the back of the veroboard.  Only a little melted plastic.  Picture below.

The project uses the techniques described in the previous post on Programming an ATtiny85 with an Arduino Nano.

The following code was loaded into the ATting85 using this method:

int ledA = 1;
int ledB = 2;
int ledC = 3;
int ledD = 4;
int i=0;

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pins as an output.
  pinMode(ledA, OUTPUT);
  pinMode(ledB, OUTPUT);
  pinMode(ledC, OUTPUT);
  pinMode(ledD, OUTPUT);
}

void allBlink()
{
  for (int i = 0; i < 20 ; i++)
  {
    digitalWrite(ledA, HIGH);
    digitalWrite(ledB, HIGH);
    digitalWrite(ledC, HIGH);
    digitalWrite(ledD, HIGH);
    delay(100);
    digitalWrite(ledA, LOW);
    digitalWrite(ledB, LOW);
    digitalWrite(ledC, LOW);
    digitalWrite(ledD, LOW);
    delay(100);
  }
}

void redGreenAlt()
{
  for (int i = 0; i < 20 ; i++)
  {
    digitalWrite(ledA, HIGH);
    digitalWrite(ledB, LOW);
    digitalWrite(ledC, HIGH);
    digitalWrite(ledD, LOW);
    delay(100);
    digitalWrite(ledA, LOW);
    digitalWrite(ledB, HIGH);
    digitalWrite(ledC, LOW);
    digitalWrite(ledD, HIGH);
    delay(100);
  }
}

void gapChase(boolean cw, boolean chaseHole)
{
  boolean defaultLevel = chaseHole;
  boolean positionLevel = !chaseHole;
  if (cw == true)
  {
    for (int i = 0; i < 20 ; i++)
    {
      for (int pos = 1; pos < 5; pos++)
      {
        digitalWrite(ledA, defaultLevel);
        digitalWrite(ledB, defaultLevel);
        digitalWrite(ledC, defaultLevel);
        digitalWrite(ledD, defaultLevel);
        digitalWrite(pos, positionLevel);
        delay(100);
      }
    }
  } else {
    for (int i = 0; i < 20 ; i++)
    {
      for (int pos = 4; pos > 0; pos--)
      {
        digitalWrite(ledA, defaultLevel);
        digitalWrite(ledB, defaultLevel);
        digitalWrite(ledC, defaultLevel);
        digitalWrite(ledD, defaultLevel);
        digitalWrite(pos, positionLevel);
        delay(100);
      }
    }
  }
}

// the loop routine runs over and over again forever:
void loop() {
  allBlink();
  gapChase(true, false);
  gapChase(true, true);
  redGreenAlt();
  gapChase(false, false);
  gapChase(false, true);
}

Figure 2 shows the schematic:

Figure 2 - Schematic

Figures 3 & 4 show the front & rear veroboard designs:

Figure 3 - Front Veroboard Design

Figure 4 - Rear Veroboard Design

Figure 5 shows the rear of the board giving a view of the button cell battery holder (for a 3V CR2032 cell) soldered carefully to the back of the board:

Figure 5 - Rear View

2 thoughts on “ATtiny85 Christmas Bauble

  1. A very clear and well presented blog.

    You have made good use of a small square of Veroboard.

    Soldering is good, Nice and shiny with a concave conical shape.

Leave a Reply

Your email address will not be published. Required fields are marked *