Build your own Harry Potter's Remembrall


One of most useless magic gadgets in Harry Potter saga. To be more precise Harry Potter never had a Remembrall, but his friend Neville Longbottom received that magic item from his grandmother.

Recently I’ve found an online project explaining how to build a Remembrall by yourself, exploiting a small Calliope device. But the description of the project was not complete, and the circuit appeared to not work similarly to the true Remembrall magic artifact.

Then I decided to build one by myself, but changing the main platform. I investigated for the first time the ATtiny85 microcontroller, and I found it perfect for the purpose of present project.

Project requirements

The circuit must work with a small battery, so a low power configuration with sleep cycles is needed. The circuit awakes when a vibration is detected, because the wizard shakes the Remembrall to activate it. If the wizard forgot something, the Remembrall shows a fading light with some smoke on it; otherwise it do nothing. So, the circuit can be designed as evaluating a random number once awaken by vibrations, and in some cases it power up some red leds. Some delays can be implemented to make the effect more realistic.

So the project covers the building of an ATtiny85 programming shield, and finally the making of the Remembrall.

Step 1: Build ATtiny programming shield

ATtiny85 programming shield for Arduino

Step 2: Program Arduino as ISP

Step 3: Program ATtiny85 with Remembrall code

Here is available an example code on how to handle sleep interrupts.

The PinChangeInterrupt library can be found here.

So the Remembrall code is provided below. The PB3 pin is used to drive the LED with a pulsing light, and the PB4 pin is used to wake up the ATtiny microcontroller.

The ATtiny works most of the time in sleeping mode to save battery. When a vibration put a high logic level to PB4 lin, the microcontroller exit the power saving mode, and starts the LED pulsing routine.

After the pulses, the LED is switched off and microcontroller returns to power saving mode.

// PinChangeInterrupt Library
#include <PinChangeInterrupt.h>

#include <avr/sleep.h>
#include <avr/power.h>

#define LED PB3
#define SWITCH PCINT4 // PB4

#define BIAS_MAX 2000
#define BIAS_HALF 500
#define BIAS_MIN 1

void setup ()
{
  // Set output port for LED
  pinMode (LED, OUTPUT);
  // Vibration sensor input has an external pulldown
  pinMode (SWITCH, INPUT);
  // Valid interrupt modes are: RISING, FALLING or CHANGE
  attachPCINT(digitalPinToPinChangeInterrupt(SWITCH), wakeUpNow, RISING);
}

void loop ()
{
  fadeInOut();
  goToSleep ();
}

void fadeInOut()
{
  fade(BIAS_MIN, BIAS_MAX, BIAS_MAX);
  
  digitalWrite (LED, HIGH);
  delay (2000);

  fade(BIAS_MAX, BIAS_HALF, BIAS_MAX);
  fade(BIAS_HALF, BIAS_MAX, BIAS_MAX);

  digitalWrite (LED, HIGH);
  delay (2000);

  fade(BIAS_MAX, BIAS_MIN, BIAS_MAX);  
}

void fade(unsigned from, unsigned to, unsigned totalSteps)
{
  if(from < to)
  {
    for(unsigned bias = from; bias < to; bias++)
    {
      digitalWrite (LED, HIGH);
      delayMicroseconds(bias);
      digitalWrite (LED, LOW);
      delayMicroseconds(totalSteps - bias);
    }
  }
  else
  {
    for(unsigned bias = from; bias > to; bias--)
    {
      digitalWrite (LED, HIGH);
      delayMicroseconds(bias);
      digitalWrite (LED, LOW);
      delayMicroseconds(totalSteps - bias);
    }
  }
}

void wakeUpNow()
{
  // execute code here after wake-up before returning to the loop() function
  // timers and code using timers (serial.print and more...) will not work here.
  // we don't really need to execute any special functions here, since we
  // just want the thing to wake up
}

void goToSleep ()
{
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  ADCSRA = 0; // turn off ADC
  power_all_disable (); // power off ADC, Timer 0 and 1, serial interface
  sleep_enable();
  sleep_cpu();
  //---------------  Continues from here after waking up  ---------------
  sleep_disable();
  power_all_enable(); // power everything back on
}

Step 4: Assemble Remembrall board

Following image presents the Remembrall schematic including the microcontroller, the output LED, the vibration sensor SW-18020.

ATtiny85 Remembrall board


Comments