GEOFF – the key reminder

So the key reminder is here. It combines the function of reed switch, distance sensor, speaker and IO provided by Adafruit. It simply reminds you when you open the door but forget to take the keys. More details can be found in the Instructables link above.

It’s a box (and Allan doesn’t like it) where you can put your keys on it. No it’s definitely not the best looking thing I have ever made, but hey, it means I have a lot of space to improve in the future. And giving more time (two weeks I spent on this project, one and half of them spent waiting for parts being delivered. Good job UPS!)

BOM for final project

A typical user journey could be: when the user get into the door, he put the key on the key reader and it reads the key; if the key wasn’t there,  a warning sound will be played to tell the user to put the key on it. The reader only starts to work when the reed switch detects a change of status (closed-open-closed) and the distance sensor detects the user (it is important to have double check because sometimes the door will be opened and closed just because the user want to make sure it is closed.  When the user open the door again, the reed switch turns to open and simultaneously, the key reader will search for the key again, and if it is still detected, the warning sound will be played to tell the user that he should take the key.

And maybe the reed switch should be connected to another separated board (which can be connected to the main board with Bluetooth or WiFi) because the reader can be placed somewhere far from the reed switch this way.

And here is the exercise.

Week 10 feather exercises

Everything went fine until I found that the button is missing!

So I edited the code and let the led blink itself….

Here are the ideas for final project!

The first idea is a smart lock that detects the keys via NFC, and reminds the user if they forgot them. It uses distance sensor to detect the status of the door (open? closed) and requires a speaker that plays the siren.

The second idea is a clock with a background light that changes like the lunar phase. It requires a bunch of LEDs (diffused?) and motors that can control the hands.

The third idea is from a prototype developed in the Affirming Artifacts. It is basically a torchlight controlled by a smartphone. It requires a Processing sketch on the phone and a Bluetooth adaptor that connects to the phone. It also requires batteries, some LEDs and a solid body (3D printing?).

! [exclamation mark]

So this is my big exclamation mark for Halloween.

It started from soldering the sound board, which was, well, quite painful.

(this is how it looks like after two days of soldering – unsoldering – soldering again 😦

This it is time for testing how the sensor works. It turns out it works without any driver, just plug in TWO power cables and TWO ground cables and one data cable, the result can be viewed immediately in the monitor.

Then to combine the different parts and let it work. The basic idea is, let the distance sensor detect the distance and when it reaches a value (here it is actually the value of 1000/d, since the noise is plentiful and it has an exponential growth), it turns the light on and sound board starts playing the music preset in the sd card.

The 3d printed exclamation marks has 0.8 mm walls so in dark environment it can be easily seen when the led is on.

The problem here is that the sound board cannot work simultaneously with other components, so when it starts to work, the light will stay on after the music is off.

Here is the code.

#include <Adafruit_NeoPixel.h>

#ifdef __AVR__

  #include <avr/power.h>


#define PIN            6

#define NUMPIXELS      16

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800);

int delayval = 1;

#include <WaveHC.h>

#include <WaveUtil.h>

SdReader card;

FatVolume vol;

FatReader root;

WaveHC wave;

uint8_t dirLevel;

dir_t dirBuf;

#define error(msg) error_P(PSTR(msg))

void play(FatReader &dir);

void setup() {

#if defined (__AVR_ATtiny85__)

  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);




  putstring_nl(“\nWave test!”);

  putstring(“Free RAM: “);


  //  if (!card.init(true)) {

  if (!card.init()) {

    error(“Card init. failed!”);



  uint8_t part;

  for (part = 0; part < 5; part++) {

    if (vol.init(card, part))



  if (part == 5) {

    error(“No valid FAT partition!”);


  putstring(“Using partition “);

  Serial.print(part, DEC);

  putstring(, type is FAT”);

  Serial.println(vol.fatType(), DEC);

  if (!root.openRoot(vol)) {

    error(“Can’t open root dir!”);


  putstring_nl(“Files found (* = fragmented):”); | LS_FLAG_FRAGMENTED);


void loop() {

  int sensorValue = analogRead(A5);

  if (1000/sensorValue < 2){

    for(int i=0;i<NUMPIXELS;i++){

      pixels.setPixelColor(i, pixels.Color(255,0,0));;






    else {

       for(int i=0;i<NUMPIXELS;i++){

      pixels.setPixelColor(i, pixels.Color(0,0,0));;





void error_P(const char *str) {

  PgmPrint(“Error: “);





void sdErrorCheck(void) {

  if (!card.errorCode()) return;

  PgmPrint(“\r\nSD I/O error: “);

  Serial.print(card.errorCode(), HEX);


  Serial.println(card.errorData(), HEX);



void play(FatReader &dir) {

  FatReader file;

  while (dir.readDir(dirBuf) > 0) {

    if (!DIR_IS_SUBDIR(dirBuf)

         && strncmp_P((char *)&[8], PSTR(“WAV”), 3)) {




    for (uint8_t i = 0; i < dirLevel; i++) {

       Serial.write(‘ ‘);


    if (!, dirBuf)) {

      error(“ failed”);


    if (file.isDir()) {

      putstring(“Subdir: “);



      dirLevel += 2;


      dirLevel -= 2;


    else {

      putstring(“Playing “);


      if (!wave.create(file)) {

        putstring(” Not a valid WAV”);

      } else {


        uint8_t n = 0;

        while (wave.isplaying) {


          if (!(++n % 32))Serial.println();








so far so good


Here are the essential parts for my costume in progress: the SHARP IR distance sensor which supports a distance of 1-5 meters, a speaker that could play sound files saved in the sd card, a bunch of LEDs (which are not shown in this photo because it is so much) and an arduino board (which is the one we’ve been always using).

Here is the to-do list for the coming week:

  • figure out the code and build the circuit
  • make a case for the circuit so that it can be taken anywhere
  • design and 3d-print the “!”


Here are the clips of this week’s homework.

An interesting thing is, because the neopixel LED is RGBW rather than RGB, the White seems to have a priority to control the color of LED. When adjust the value of RGB, if the white remains 255, the color does not change at all.