Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Tomáš Pastorek
Published © CC BY-NC

Smart LEGO Duplo Brick

CR2032 coin battery and ATtiny are small enough to fit inside a LEGO Duplo brick. Hmm... Let's create something to play.

IntermediateFull instructions provided6 hours1,771
Smart LEGO Duplo Brick

Things used in this project

Hardware components

Microchip ATTiny13
×1
High Brightness LED, White
High Brightness LED, White
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1
Coin Cell Battery CR2032
Coin Cell Battery CR2032
×1
Battery Holder, 2032 x1
Battery Holder, 2032 x1
×1
Resistor 100 ohm
Resistor 100 ohm
×1
TE Connectivity DIP8 Socket
×1
Self-tapping screw 2.5x12
×3

Software apps and online services

Fusion
Autodesk Fusion

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

Top part with studs

Bottom part

Button

Switch holder, part 1

Switch holder, part 2

Schematics

Schema

Code

smart-lego.ino

Arduino
I used Arduino IDE to upload this code to ATTiny via Arduino as ISP
#include <avr/sleep.h>

#define adc_disable() (ADCSRA &= ~(1<<ADEN)) // disable ADC (ADC uses ~320uA)

const int LED_PIN = 0;
const unsigned long SLEEP_AFTER_MILIS = 60000; // sleep after 1 min

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  adc_disable();
}

void enterSleep()
{
  cli(); // disable all interrupts
  WDTCR = 0; // turn off the Watchdog timer
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  adc_disable();
  sleep_enable();
  sleep_cpu();
}


void loop()
{
  digitalWrite(LED_PIN, HIGH);
  do
  {
    delay(1000);
  } while (millis() < SLEEP_AFTER_MILIS);
  
  digitalWrite(LED_PIN, LOW);
  delay(1000);
  enterSleep();
  
  // ...continue after reset
}

Credits

Tomáš Pastorek
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.