GEOFF – the key reminder

https://www.instructables.com/id/GEOFF-Never-Forget-Your-Keys-Again/

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.

https://drive.google.com/file/d/1p8_3Psz-BwsvFyk5WaVkUpRjm8Pixe-s/view?usp=sharing

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….

https://photos.app.goo.gl/YAbJNKAYSofp4Hav6


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>

#endif

#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);

#endif

  pixels.begin();

  Serial.begin(9600);

  putstring_nl(“\nWave test!”);

  putstring(“Free RAM: “);

  Serial.println(FreeRam());

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

  if (!card.init()) {

    error(“Card init. failed!”);

  }

  card.partialBlockRead(true);

  uint8_t part;

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

    if (vol.init(card, part))

      break;

  }

  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):”);

  root.ls(LS_R | 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));

      pixels.show();

      delay(delayval);

     }

    root.rewind();

    play(root);

  }

    else {

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

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

      pixels.show();

      delay(delayval);

   }

 }

}

void error_P(const char *str) {

  PgmPrint(“Error: “);

  SerialPrint_P(str);

  sdErrorCheck();

  while(1);

}

void sdErrorCheck(void) {

  if (!card.errorCode()) return;

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

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

  PgmPrint(,);

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

  while(1);

}

void play(FatReader &dir) {

  FatReader file;

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

    if (!DIR_IS_SUBDIR(dirBuf)

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

      continue;

    }

    Serial.println();

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

       Serial.write(‘ ‘);

    }

    if (!file.open(vol, dirBuf)) {

      error(“file.open failed”);

    }

    if (file.isDir()) {

      putstring(“Subdir: “);

      printEntryName(dirBuf);

      Serial.println();

      dirLevel += 2;

      play(file);

      dirLevel -= 2;

    }

    else {

      putstring(“Playing “);

      printEntryName(dirBuf);

      if (!wave.create(file)) {

        putstring(” Not a valid WAV”);

      } else {

        Serial.println();

        wave.play();

        uint8_t n = 0;

        while (wave.isplaying) {

          putstring(“.”);

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

          delay(100);

        }

        sdErrorCheck();

      }

    }

  }

}

so far so good

iri6hg

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 “!”

hideo-kojima-point-d-exclamation-mgsv

Here are the clips of this week’s homework.

https://drive.google.com/open?id=1CttWO1krEfNtzOHGByI3muPIjo2rq9Ut

https://drive.google.com/open?id=1feKFgweQAljWnGlbvzszlEcgPDctVqrk

https://drive.google.com/open?id=1S1zMlR79tLdgpTtjK4gRNz-BdnyutH4c

https://drive.google.com/open?id=129fhKAqnMd3WB5wFayaQR3azqFeYs6wN

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.