Project: GlowStone

This project requires Arduino and s2aio extension, and also an audio speaker or headphones.

What It Does

Into the solidity of stone, a solidity yet capable of suffused light, the fantasies of bodily vigor, of energy in every form, can be projected, set out and made permanent.
—Adrian Stokes, Stones of Rimini

The stone symbolizes physicality, concretization, manifestation, and sometimes completion or perfection: “virtus eius integra est si versa fuerit in terram.” The living stone is a perfect example of animism; not merely juxtaposing inert matter with vibrant and intelligent activity, but transcending their contrast. The golem is dead matter brought to life by breath and word—like the electricity and code that animates robots. The Philosopher’s Stone is the perfection of the alchemical Magnum Opus, being the utmost condensation of the supreme agent of transmutation (viz., AZOTH). &c.

GlowStone is a special kind of lamp that anchors a technomancer’s power and helps her to recall it whenever needed. It involves a selenite crystal tower illumed by an RGB LED controlled by Arduino, and audio instructions that lead the technomancer through a Meta-Magick exercise coordinated with the stone’s illumination.1

How It Works

GlowStone was written for the s2aio extension that adds blocks for interacting with Arduino. The extension should work on Windows, Mac, and Linux including Raspberry Pi’s Raspbian. If you download and open the GlowStone project file in the editor without s2aio running on your computer, the project will not run correctly.

There is an Arduino extension for the online Scratch 2 editor, hosted by ScratchX, but it does not currently work with any up-to-date web browsers. I expect a new extension to be written for Scratch 3, and will add information about that here when it happens.

A Little LED Theory

The most basic law of electronics, Ohm’s law, mathematically expresses the relationships between electric current, voltage, and resistance. Imagine that electricity moving through a circuit is like water flowing through a pipe. Current (I) is the flow of electricity through the circuit; it can be a little (trickle) or a lot (gush), and it can go slowly or rapidly. Voltage (V) is the force pushing the current along. Resistance (R) is anything that resists the flow, including the “pipe” (circuit wire) itself. Ohms’s law says that current equals voltage divided by resistance (I = V / R); voltage equals current times resistance (V = IR); and resistance equals voltage divided by current (R = V / I). In other words, current is proportional to voltage and inversely proportional to resistance. You can increase current by increasing voltage or decreasing resistance, and you can decrease current by decreasing voltage or increasing resistance. Sorted? Good! If not, fret not, for SparkFun has a proper tutorial on this subject.

A diode is an electronic component that passes current in only direction. A light-emitting diode (LED) generates light in response to the current it passes. Regular LEDs have two leads (the wires protruding from the housing): an anode that connects to a positive voltage source and moves electricity into the LED, and a cathode that connects to ground and moves electricity out of the LED. The housing typically has a flat edge on the cathode side, and the anode lead is typically longer or bent, to help you identify which side is which.

GlowStone LED

A resistor (so called because it resists the current flow) is usually needed in serial with the LED to limit the amount of current the LED passes. Unlike LEDs which are polarized and need to be oriented a certain way within a circuit, resistors work the same whichever direction they are connected in.

GlowStone polarity
Made with Fritzing assets

Now, can mix red, green, and blue light to produce a large range of visible colors. An RGB LED is a red, a blue, and a green LED in a single housing with four leads: one for each color and a common cathode or common anode (the longest lead identifies which is common).

GlowStone RGB LED

GlowStone uses a common cathode LED that is connected to a ground header on the Arduino board while the red, green, and blue leads are connected to PWM headers via resistors.

GlowStone wiring
Made with Fritzing assets

Pulse width modulation allows us to vary the amount of voltage supplied to each of the three colored LEDs, letting us control the brightness of each color. The range of 0 to 5 volts supplied to each colored LED is represented by a PWM range of 0 to 255, so we can use the well-known web color space to find and specify which color we want the LED to glow. E.g, the RGB decimal triplet for the color deep pink is (255, 20, 147), so by setting the Arduino pins for the red, green, and blue LEDs to to values 255, 20, and 147, respectively, the LED will glow a deep pink color (more or less; variations in LED brightness and resistor values can cause an LED connected to Arduino to glow not quite the same color you see on your computer screen).

Dais Construction & Wiring

GlowStone dais

I made a small dais to conceal the Arduino and LED beneath the crystal tower, prepared much like the accumulator I made for SIBOR. Here is a parts list:

  • Arduino Uno R3 w/ USB cable
  • 5mm diffused common cathode RGB LED
  • three 270Ω resistors (band colors: red, violet, brown; higher values may be used but will dim the light)2
  • one 4″ × 4″ × 1-1/2″ wood panel
  • four decorative feet w/ screws

GlowStone foot

I cut some cardboard strips and hot-glued them together to make a shim, and hot-glued the Arduino to that (I like hot glue for this kind of thing because it easy to remove with some rubbing alcohol or solvent such as Bestine).

GlowStone shim

A glob of hot glue secures the LED inside the 5mm hole drilled into the panel’s center.

GlowStone wiring 2

GlowStone panel

Using round-nose pliers I made small loops in one end of each resistor, to place around the LED’s leads. I did the same with a bit of 22-gauge wire for the cathode-to-ground connection. A dab of Bare conductive paint on each connection secures the wires and helps make an electrical contact (typically I would use solder for this).

GlowStone wiring 3

Running s2aio

After you have followed the instructions on the s2aio website to install and configure the extension and your Arduino, and made something to hold the electronics beneath your crystal tower, connect Arduino to a USB port on your computer and then run s2aio in no-client mode (which prevents s2aio from opening a new instance of the Scratch editor) by inputting s2aio -c no-client at a command prompt.

GlowStone s2aio

With s2aio running, open the GlowStone.sb2 file in the Scratch offline editor, and start the project by clicking the green flag. A voice will talk you through the exercise, which includes a test to verify the RGB LED is connected and working correctly.

You can specify your own color of magic (or whichever color you associate with technomancy in particular) for the stone to glow during the exercise. The variables magicRed, magicGreen, and magicBlue record the decimal triplet for your desired color. E.g., if your color of magic is cyan, which has an RGB triplet of (0, 255, 255), you would set magicRed = 0, magicGreen = 255, and magicBlue = 255, before running the project.

GlowStone script initial

The variables redPin, greenPin, and bluePin identify which Arduino pins are connected to the red, green, and blue leads of the RGB LED. If you need to change a pin, e.g., swap pin 6 for 9 to use are you blue pin, you can just set bluePin to 6 at the beginning of the initial script, instead of having to change it everywhere that pin is written to throughout the project.

To fade the LED color in and out requires successively increasing or decreasing the PWM values written to the R, G, and B pins. Recall the PWM value has a range of 0 to 255, with 0 being the dimmest (essentially off), and 255 being the brightest. The only color that has all three pins set to 255 is white; all other colors require one or more of the LEDs to be dimmer than 255. For the color deep pink, which has an RGB triplet of (255, 20, 147), the range for the red pin to fade in is 0 to 255, but the range for the green pin is only 0 to 20, and for the blue pin it is 0 to 147. To proportionately adjust all three pins at the same time, we can map all of them to the maximum possible range, 0 to 255, so that it takes the same length of time for the red pin to go from 0 to 255 as it does for the green pin to go from 0 to 20, and the blue pin from 0 to 147.

GlowStone map

If you are using a common anode LED instead of common cathode, you must connect the common pin to +5 volts instead of to ground. Under this configuration, each LED glows brightest when set to 0, and dimmest when set to 255. To keep the math simple, you can simply take all the values you would use under a common cathode configuration, and subtract them from 255. E.g., to set a common cathode LED to deep pink (255, 20, 147), you would do this:

GlowStone DeepPink common cathode

To do the same thing for a common anode LED:

GlowStone DeepPink common anode

Make It Better

  • Paint arcane glyphs onto the dais.
  • Add a switch to turn the lamp on and off.
  • Reprogram GlowStone to automatically turn on or change colors at particular times as reminders of tasks you need to perform.
  • Reprogram GlowStone for divination by assigning meanings to colors or blinks. You could add multiple LEDs and stones to the project and make them glow different colors or in different patterns.
  • Replace the spoken exercise with one of your own recording. If you have a microphone embedded in or attached to your computer, you can record your voice right in Scratch.
  • Experiment with different interactions. E.g., project your anger into the stone as the color red, have the stone morph to a cool blue, and then absorb that blue color into your body—how does that make you feel?
  • Replace the Arduino Uno with an Arduino Pro Mini, Arduino Nano, or other compatible board to decrease the hardware footprint.
  • Go bigger! Replace the single RGB LED with three LEDs (one red, one green, and one blue) to illume a larger stone, or try this project with a light bulb or string of lamps using an Arduino-controlled dimmer made with a ZeroCross Tail.

  1. The GlowStone Meta-Magick exercise combines parts of “Exercise 2.3 Energy Flow Modeling” and “Exercise 3.1 Simple Evocations” from Philip H. Farber, Brain Magick: Exercises in Meta-Magick and Invocation (Llewellyn, 2011).
  2. A little more LED theory follows. The precise value of a resistor needed in series with an LED depends on the circuit’s current (measured in amperes), the voltage (in volts) supplied to the LED, and the LED’s “forward voltage” or “voltage drop,” which is usually specified by the LED’s manufacturer. The individual red, green, and blue LEDs within a single RGB LED may have different forward voltages and so optimally require different resistor values. However, using an approximate value is usually alright, at least in the short term. If you want to know more, SparkFun also has an LED tutorial.