Anouk Wipprecht
Published © GPL3+

Light Up Kitty Ears!

This 3D printed headset comes with custom cat-ear PCBs, created in Autodesk EAGLE and printed at OSHPark!

EasyFull instructions provided3 hours3,199
Light Up Kitty Ears!

Things used in this project

Hardware components

5mm LED (need 8 of them) Bright White
×8
ATTINY85-20PU-ND
×1
Coin Cell Battery Holder
×1
Resistor 10 OHM (need 2 of them)
×1
Tactile Switch
×1
Coin Cell Battery 3V
×1
Custom fabricated PCB
OSH Park Custom fabricated PCB
×1

Software apps and online services

Fusion 360
Autodesk Fusion 360
Autodesk EAGLE
Arduino IDE
Arduino IDE
OSH Park OSHPark Custom PCB Print

Hand tools and fabrication machines

Dremel 2050-15 Stylo+
Dremel 3D45 3D Printer
Soldering iron (generic)
Soldering iron (generic)
Pliers

Story

Read more

Custom parts and enclosures

Anouk_kitty_ears_3Dmodel

3D model of cat ear headband for 'Light Up Kitty Ear' tutorial to print for example in SLS (nylon) or on an home-3D printer (I used the Dremel 3D45 3D Printer + grind support material off using the Dremel 2050 Stylo+ tool and grinding bits)

Schematics

Light Up Kitty Ears CIRCUIT

Light Up Kitty Ears circuit

Light Up Kitty Ears GERBER

Light Up Kitty Ears Gerber file ZIP

Code

Light Up Kitty Ears CODE

Arduino
Blinking boards in cat-ear shape <3
Programmed with an ATTINY85-20PU

3 different kinds of animation included
#include <avr/sleep.h>
#include <avr/interrupt.h>

#define PIN_LED_0  0
#define PIN_LED_1   1
#define PIN_LED_2   2
#define PIN_LED_3   3
//#define PIN_SWITCH  3

#define PIN_STATE_NO_CHANGE   0
#define PIN_STATE_INPUT         1
#define PIN_STATE_LOW           2
#define PIN_STATE_HIGH          3

void setPin(int pin, int state) {
  switch (state) {
    case PIN_STATE_INPUT:
      pinMode(pin, INPUT);
      digitalWrite(pin, LOW);
      break;
    case PIN_STATE_LOW:
      digitalWrite(pin, LOW);
      pinMode(pin, OUTPUT);
      break;
    case PIN_STATE_HIGH:
      digitalWrite(pin, HIGH);
      pinMode(pin, OUTPUT);
      break;
  }
}

void setLedPins(int pin0, int pin1, int pin2, int pin3) {
  setPin(PIN_LED_0, pin0);
  setPin(PIN_LED_1, pin1);
  setPin(PIN_LED_2, pin2);
  setPin(PIN_LED_3, pin3);
}

void setLed(int led, bool on = true) {
  switch (led) {
    case 0:
      setLedPins(
        on ? PIN_STATE_HIGH : PIN_STATE_LOW,
        PIN_STATE_INPUT,
        on ? PIN_STATE_LOW : PIN_STATE_HIGH,
        PIN_STATE_INPUT);
      break;
    case 1:
      setLedPins(
        on ? PIN_STATE_LOW : PIN_STATE_HIGH,
        PIN_STATE_INPUT,
        on ? PIN_STATE_HIGH : PIN_STATE_LOW,
        PIN_STATE_INPUT);
      break;
    case 2:
      setLedPins(
        PIN_STATE_INPUT,
        on ? PIN_STATE_HIGH : PIN_STATE_LOW,
        on ? PIN_STATE_LOW : PIN_STATE_HIGH,
        PIN_STATE_INPUT);
      break;
    case 3:
      setLedPins(
        PIN_STATE_INPUT,
        on ? PIN_STATE_LOW : PIN_STATE_HIGH,
        on ? PIN_STATE_HIGH : PIN_STATE_LOW,
        PIN_STATE_INPUT);
      break;
    case 4:
      setLedPins(
        on ? PIN_STATE_HIGH : PIN_STATE_LOW,
        PIN_STATE_INPUT,
        PIN_STATE_INPUT,
        on ? PIN_STATE_LOW : PIN_STATE_HIGH);
      break;
    case 5:
      setLedPins(
        on ? PIN_STATE_LOW : PIN_STATE_HIGH,
        PIN_STATE_INPUT,
        PIN_STATE_INPUT,
        on ? PIN_STATE_HIGH : PIN_STATE_LOW);
      break;
    case 6:
      setLedPins(
        PIN_STATE_INPUT,
        on ? PIN_STATE_HIGH : PIN_STATE_LOW,
        PIN_STATE_INPUT,
        on ? PIN_STATE_LOW : PIN_STATE_HIGH);
      break;
    case 7:
      setLedPins(
        PIN_STATE_INPUT,
        on ? PIN_STATE_LOW : PIN_STATE_HIGH,
        PIN_STATE_INPUT,
        on ? PIN_STATE_HIGH : PIN_STATE_LOW);
      break;
  }
}

bool getButton(void) {
  setLedPins(
    PIN_STATE_INPUT,
    PIN_STATE_LOW,
    PIN_STATE_INPUT,
    PIN_STATE_INPUT);
  digitalWrite(PIN_LED_0, HIGH);
  delay(5);
  bool result = (digitalRead(PIN_LED_0) == LOW) ? true : false;
  setLedPins(
    PIN_STATE_INPUT,
    PIN_STATE_INPUT,
    PIN_STATE_INPUT,
    PIN_STATE_INPUT);
  digitalWrite(PIN_LED_0, LOW);
  return result;
}

void sleep() {

    GIMSK |= _BV(PCIE);                     // Enable Pin Change Interrupts
    PCMSK |= _BV(PCINT3);                   // Use PB3 as interrupt pin
    ADCSRA &= ~_BV(ADEN);                   // ADC off
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);    // replaces above statement

    sleep_enable();                         // Sets the Sleep Enable bit in the MCUCR Register (SE BIT)
    sei();                                  // Enable interrupts
    sleep_cpu();                            // sleep

    cli();                                  // Disable interrupts
    PCMSK &= ~_BV(PCINT3);                  // Turn off PB3 as interrupt pin
    sleep_disable();                        // Clear SE bit
    ADCSRA |= _BV(ADEN);                    // ADC on

    sei();                                  // Enable interrupts
    } // sleep

ISR(PCINT0_vect) {
    // This is called when the interrupt occurs, but I don't need to do anything in it
}

// the setup routine runs once when you press reset:
void setup() {
  pinMode(PIN_LED_0, INPUT);
  pinMode(PIN_LED_1, INPUT);
  pinMode(PIN_LED_2, INPUT);
  pinMode(PIN_LED_3, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  static int led = 0;
  static bool on = true;
  
  static bool lastButton = false;
  bool button = false;

  button = getButton();
  if (button != lastButton) {
    if (button) {
      on = !on;
    } else if (!on) {
      // Time to go to sleep
      setLedPins(
        PIN_STATE_INPUT,
        PIN_STATE_LOW,
        PIN_STATE_INPUT,
        PIN_STATE_INPUT);
      digitalWrite(PIN_LED_0, HIGH);
      for (bool wake = false; !wake; ) {
        sleep();
        delay(20);
        if (digitalRead(PIN_LED_0) == LOW) {
          wake = true;
        }
      }
      on = button = true;
    }
    lastButton = button;
  }

  if (on && !button) {
    setLed(led, true);
  } else {  
    setLedPins(
      PIN_STATE_INPUT,
      PIN_STATE_INPUT,
      PIN_STATE_INPUT,
      PIN_STATE_INPUT);
  }
  
  if (++led >= 8) led = 0;
  delay(25);

}

Credits

Anouk Wipprecht

Anouk Wipprecht

1 project • 18 followers
Dutch FashionTech Designer, Tinkerer and Creative.

Comments