2017-01-05

Monster-B-Gone

Last year Make:Magazine had an article where they built a Monster-B-Gone detector. I did not had the same processor board (a trinket) and having a stash of Attiny15L, I thought I could use them instead.



There is one big problem with this MPU, speed. It only runs at 1.6MHz, meaning that the cycle time is 625ns. The Neopixel needs a feed of serial zeros and ones where minimum on-time is about half of that.
So I needed to get clever...
First I read a lot about Neopixels (here and here), then I decided to use the PWM generator to drive the Neopixels with the PLL, this would allow a faster impulse generation that the processor could do.
I had to compromise on the number of colors available (only 7) but in the end it worked. So that the 8 bits of a color byte always have the same value (there are 3 color bytes for each pixel). This not only is needed because of the speed, but also because the processor only has 32 byte registers.
The other components is a LiPo battery, a LiPo charger, a push button (resets the processor) and the neopixel (all from adafruit).


My Kids required one each... so ...


How it works required lot of cycle counting, but in the end I made it work! So first set up the PLL for a suitable upscaled frequency, then create the rolling blue light (walking one) and after some random rounds, show the green ring (room clean). There are lots of discussions if it should occasionally show the red light (MONSTER IN ROOM). I decided it should never show the red light, but changing the code to use the same random number generator to decide should be easy.

video
 The code is here.

No comments: