HackerBox 0059: Tessellate

by HackerBoxes in Circuits > Arduino

7801 Views, 22 Favorites, 0 Comments

HackerBox 0059: Tessellate

WholeBoxInstruct0059.png

Greetings to HackerBox Hackers around the world!

With HackerBox 0059 we'll explore inductors, construct a clever inductance meter, wind custom inductors, program the USB Digispark to control the excusive Hack-O-Lantern ornament, configure the WEMOS ESP32 Lite for use with the Arduino IDE, integrate a high resolution 3-axis accelerometer, and assemble tessellations of triangular PCB tiles into both flat and 3-dimesional geometries.

HackerBoxes is the monthly subscription box service for enthusiasts of electronics and computer technology - Hardware Hackers - The Dreamers of Dreams.

There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we really appreciate your taking a few minutes to read the FAQ.

Supplies

This Instructable contains information for getting started with HackerBox 0059. The full box contents are listed on the product page for HackerBox 0059 where the box is also available for purchase while supplies last. If you would like to automatically receive a HackerBox like this right in your mailbox each month with a $15 discount, you can subscribe at HackerBoxes.com and join the revolution!

A soldering iron, solder, and basic soldering tools are generally needed to work on the monthly HackerBox. A computer for running software tools is also required. Have a look at the HackerBox Deluxe Starter Workshop for a set of basic tools and a wide array of introductory activities and experiments.

Most importantly, you will need a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help

Hack-O-Lantern

HAPPY HALLOWEEN

The Exclusive HackerBox Hack-O-Lantern kit uses an onboard USB Digispark as its controller and USB power connector. Two addressable RGB LEDs serve as frightfully colorful eyeballs and a piezo buzzer produces truly horrifying sounds.

USB Digispark

Digispark.png

The Digispark is an ATTiny85 based microcontroller development board similar to the basic Arduinos, only smaller and a bit less powerful. The Digispark is a great place to jump into microcontrollers, or perfect for when an Arduino is too large or simply overkill.

BEFORE SOLDERING to the USB Digispark, test the module out on its own and make sure your tools are set up to program it correctly. Follow the instructions under "Original Digispark - Getting Started" on the Digispark Documentation Wiki to set up support for the Digispark in the Arduino IDE. Next load some initial blinky LED sketches onto the ATTiny 85 to get oriented to the board.

Note that the Digispark does not have any dedicated hardware to connect to USB. Instead, the Digispark comes preloaded with Micronucleus to bit-bang USB signals from software. Micronucleus is a bootloader designed for AVR ATTiny microcontrollers with a minimal usb interface, cross platform libusb-based program upload tool, and a strong emphasis on bootloader compactness. It is, by far, the smallest USB bootloader for the AVR ATTiny.

Assemble and Program the Hack-O-Lantern

Assemble HackOLantern.png

Hack-O-Lantern LED Eyes

Solder two WS2812B RGB LEDs onto the front side of the PCB for eyes. Mind how the LEDs are orientated or they will not operate correctly. The white triangle corners of the LEDs go in the upper left corner on the PCB landing as shown by the red triangles on the image above. As can be seen in the example code, the data pin for the LEDs is attached to I/O P0 of the Digispark.

Hack-O-Lantern Squawk Box

Solder the buzzer onto the back of the PCB with the dot designating pin one oriented down closest to the "+" symbol on the silkscreen.

As can be seen in the example code, the the buzzer is attached to I/O P2 of the Digispark.

Hack-O-Lantern Brain

Solder both rows of header pins onto the USB Digispark module such that the pins extend from the rear of the Digispark (opposite side from the components). After the headers are soldered in, carefully slide the plastic spacers off of the headers. This will allow the Digisark to sit flush against the back of the Hack-O-Lantern. Mount the Digispark onto the BACK of the Hack-O-Lantern PCB. While wearing safety glasses, trim the leads (nearly) flush on both sides of the Digispark and the Hack-O-Lantern. Touch the soldering iron very briefly to the freshly cut header "wounds" to make them smooth with solder.

Hack-O-Lantern Program Code

From the Arduino IDE, program the USB Digispark with the HackOLantern.ino sketch included here. Stand the Hack-O-Lantern up into a USB power pack for a horrifying Halloween display!

Downloads

WEMOS ESP32 Lite

WEMOS ESP32 Lite.png

The ESP32 is a low-cost, low-power system on a chip (SOC) with integrated Wi-Fi and dual-mode Bluetooth.

Make your initial test of the WEMOS ESP32 module BEFORE soldering the header pins onto the module.

Set up the ESP32 support package in the Arduino IDE.

Under tools>board in the Arduino IDE, select the "WeMos LOLIN32"

Load the example code at Files>Examples>Basics>Blink and program it to the WeMos LOLIN32

The example program should cause the LED on the module to blink. Experiment with modifying the delay parameters in the sketch code and re-programming it into the module. This will make the LED blink with different patterns. This is always a good exercise to build confidence in programming a new microcontroller module.

Once you are comfortable with the module's operation and how to program it, carefully solder the two rows of header pins into place and test program downloading again.

Inductors

An inductor (wikipedia) is also known as a coil, choke, or reactor. It is a passive two-terminal electrical component that stores energy in a magnetic field when electric current flows through it. An inductor typically consists of an insulated wire wound into a coil around a core. When the current flowing through an inductor changes, the time-varying magnetic field induces an electromotive force (voltage) in the conductor, described by Faraday's law of induction. According to Lenz's law, the induced voltage has a polarity (direction) which opposes the change in current that created it. As a result, inductors oppose any changes in current through them.

Inductance Meter Kit

Inductance Meter.png

Components:

  • Green Prototyping Board 4x6 cm
  • LM393 Comparator IC (8 Pin DIP)
  • 1uF Poly Film Capacitor
  • 1N4001 Diode
  • 330 Ohm Resistor
  • 150 Ohm Resistor
  • Six Red Header Pins
  • 330uH Toroid Inductor

The Inductance meter can be assembled on a prototype board as shown, which is always good practice, or it can be assembled on a solderless breadboard if you prefer. The meter works with pretty much any microcontroller at either 3.3V or 5V including the WEMOS ESP32, or just about any Arduino Board.

The attached Arduino Sketch (L_Meter) has two pin defines (kickpin 27 and sensepin 26) which can be updated to whichever pins are used with the meter circuit.

Test the Inductance Meter with the 330uH Toroid Inductor. It should measure within 10-20uH of the nominal value.

Theory of Operation

The MCU drives the "kickpin" high to charge up the LC tank circuit. L is the unknown Inductor (Device Under Test) and C is the 1uF Poly Film Capacitor. When "kickpin" in released to low by the MCU, the LC tank will ring at a frequency determined by L and C. This frequency can be measured by turning the ringing sinusoid into square pulses using a fast comparator IC. The square pulses are read into the MCU at sensepin and the measured pulse frequency allows us to calculate L.

Mechanical Analogy

The LC portion of the circuit is a resonator, just like a mass on a spring, or a bob on a pendulum. You can set up a pendulum and "kick" it so that it swings back and forth. The period of the swing (or "ringing") can be measured with a stop watch. Since the period is sqrt(L/g) and g is a constant of gravitational acceleration, the measured period allows us to calculate "L" which is the length of the pendulum. It doesn't mater how high you displace (kick) the pendulum or how much mass is on the end since it will have the same period regardless. Likewise, it doesn't mater how much we charge the LC tank circuit (for example, with 3.3V or 5V) prior to letting it ring to time its period.

DIY Inductors

While it is a bit difficult, or at least unorthodox, to make our own resistors or capacitors, we can easily wind custom wire inductors. For example, try winding about 200 turns of the copper magnet wire onto a PVC pipe, large pill bottle, dowel, or film canister. Check the inductance with the meter. Compare it to the theoretical value by entering the coil diameter, coil length, and number of turns of your DIY inductor into this calculator. The measured and theoretical values should be quite close.

Downloads

Tessalation

Tessellation.png

Tessellation (wikipedia) is covering a flat surface using one or more geometric shapes, called tiles, with no overlaps and no gaps. In mathematics, tessellations can be generalized to higher dimensions and a variety of geometries.

A periodic tiling has a repeating pattern. Some special kinds include regular tilings with regular polygonal tiles all of the same shape, and semiregular tilings with regular tiles of more than one shape and with every corner identically arranged.

We will focus on tiles approximating equilateral triangles like the black PCBs rendered in the image above.

Assemble the White Triangle Tile

White Tile.png

LEDs

Solder six WS2812B RGB LEDs onto the front side of the white tile. Orient each LED such that the white triangle is in the corner with the small flag designator on the silkscreen placement of the LED.

Triple Axis Accelerometer

The ADXL345 (datasheet) is a tiny, low power, 3-axis MEMS accelerometer with high resolution (13-bit) measurement. Digital output data is formatted as 16-bit twos complement and is accessible through either a SPI (3- or 4-wire) or I2C digital interface. The ADXL345 is well suited to measure the static acceleration of gravity in tilt-sensing applications.

Mount the ADXL345 module on the rear side (opposite the LEDs) of the white tile. Orient the module such that the VCC and GND markings of the module align with those on the tile PCB. Similarly, the SCL and SDA pins of the ADXL module align with the IO16 and IO17 markings on the tile PCB. Once solder into place, trim the header pins of the AXDL module on the front side of the white tile since this is where the ESP32 module will be placed.

WEMOS ESP32 Lite

Carefully solder the two rows of header pins from the ESP32 module onto the front side of the white tile. Once soldering into place, program the attached sketch TiltColors to demonstrate basic control of the LED colors by tilting the tile.

Downloads

Interconnecting Tessellated Circuit Boards

Connecting Tiles.png

Each of the black tiles has six WS2812 RGB LEDs in a chain on the front of the PCB. The chain is fed from the data in (DIN) pad. The end of the chain continues to either DOUT-A or DOUT-B depending upon how the A/B "switch" is set. The setting is made by bridging a blob of solder (or a tiny length of wire) from the center pad of the "switch" to the pad labeled A or B (but never both).

Whichever DOUT pad is select is aligned with the DIN of the neighboring triangle. This allows a path through multiple tiles to be traversed. The arrows in the diagram show examples of the LED data path being properly connected among a tessellation of triangular tiles. The last black tile in the chain should have neither A or B shorted in the A/B "switch".

All of the edge pads should be jumped between neighboring tiles. The center pad contains the LED data signal (if selected) and the outer four pads connect power and ground. The jumpers can be made with short pieces of stiff wire, such as the included magnet wire. When using magnet wire, the thin insulating coating can be removed using a blade or sandpaper to allow solder to flow onto the metal.

Remember to update the "number of LEDs" specified in the code to six times the number of connected tiles. There is also a for loop at the very end of the file in the function UpdateLEDs() that cycles through the first six LEDs setting the colors. This should be updated to however many LEDs you want to light up. However, you might not want to light up all of the LEDs at once unless you keep the brightness very low or use a beefy power source. Large numbers of brightly lit LEDs can draw a lot of current.

Platonic Solids

SOLIDS.png

A platonic solid (wikipedia) is a three-dimensional, regular, convex polyhedron. It is constructed from congruent (identical in shape and size), regular (all angles equal and all sides equal), polygonal faces with the same number of faces meeting at each vertex. There are five solids that meet these criteria. They are the tetrahedron, cube, octahedron, dodecahedron, and the icosahedron.

In addition to flat tessellations, our triangle PCB tiles can be arranged three-dimensionally into any of the three platonic solids having triangular faces: the tetrahedron (4 faces), octahedron (8 faces), or icosahedron (20 faces). The flattened "nets" of those three solids in the image illustrate example "connected path transversals" that can be used to route the LED signals (DIN/DOUT) through each face once and only once.

A lithium polymer (LiPo) battery can be connected to the WEMOS ESP32 Lite board and placed inside the polyhedron before the tiles are soldered together.

While they are generally not required, the two 1000uF can be placed into the center of two of the black tiles to smooth out the power supply. The capacitors can be placed inside the polyhedron. The polarity of each capacitor must be aligned with the "+" marking on the PCB silkscreen.

When used with tiles in a polyhedral geometry, the example code could be modified such that each face is a different color and the colors respond to the tilt sensor or "rolling" of the polyhedron like a die.

HackerBox 0059 Expansion Pack

While enough tiles are included in HackerBox 0059 to construct the tetrahedron or octahedron, 12 additional black triangle tiles (and associated LEDs) are required to construct the icosahedron. A very limited number of expansion packs providing these extra parts are available for sale here.

Musical Instrument Challenge

In addition to the LED colors shifting in response to the IMU as you rotate the object, we could use some sound effects! The ESP32 supports Bluetooth which can be used to turn your 3D tessellation into a MIDI instrument that generates notes as it is rotated.

MIDI (Musical Instrument Digital Interface) is a technical standard that describes a communications protocol, digital interface, and electrical connectors that connect a wide variety of electronic musical instruments, computers, and related audio devices for playing, editing and recording music. The specification originates in a paper published all the way back in 1981. (Wikipedia)

Adafruit Guide on Web MIDI and BLE MIDI

BLE MIDI Demo for ESP32

Hack the Planet

outro.png

We hope you are enjoying this month's HackerBox adventure into electronics and computer technology. Reach out and share your success in the comments below or other social media. Also, remember that you can email support@hackerboxes.com anytime if you have a question or need some help.

What's Next? Join the revolution. Live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month. Surf over to HackerBoxes.com and sign up for your monthly HackerBox subscription.