DIY Custom Light Performance

The motivation for this project was to create a controller that allows users to “play” light like it is an instrument with gesture control, custom visuals, and brightness/speed dials.

Considering how pricey consumer light controllers can be (often $100 bucks or more- not including the lights!) we decided to make a cheaper, more customizable solution! One aspect of this project that we were particularly excited about was the low barrier to entry. Most users pick up the controller in 2-3 songs, unlike other light toys (gloving, poi, ect) that require a much larger practice investment.

Here is our approach, you are welcome to use as-is or modify the project for all of your wild and wonderful needs!

Build Time: 2-3 hours 

Estimated Cost: $80 of materials

Project Materials

Case/Mounting Board (I used a wood box from a craft store)
Seeed Grove Sound Sensor v1.6 (Optional- Not used in this version)
Addressable LED Strips (2-3)
Rotary Potentiometer (2)
Digilent Pmod KYPD
Ultrasonic Rangefinder
Arduino UNO

Project Tools

Dremel
Soldering Iron
Hot glue gun

Build Overview

Design Considerations

One of the challenges with a project like this is the number of buttons it needs. Even in my more conservative designs, I wanted to have around 8 buttons to manage the different visual sequences, color palettes, and other mode selection. Wiring up that many buttons can be tedious and adds more points of failure. Additionally, the Arduino Uno board has a limited number of digital inputs. Luckily, the Pmod KYPD solves both of these issues!

The Pmod KYPD’s small form-factor allows it to fit neatly onto any baseboard without taking up too much space. I am using a free wood sample I got from my local hardware store as my mounting panel.

Electrical Schematic

Build Process

1. Start by connecting the Pmod KYPD to the Arduino Uno digital pins as shown in the above Fritzing diagram.

2. Next, wire in your potentiometers to Analog Pins A5 (brightness) and A4 (speed).

3. Attach the LED Strips to Ground and 5V, then wire both signal pins into Digital Pin 11.

4. Wire up the sound sensor to power and ground, and the white wire to A1 and yellow wire to A0.

If you do not have the connecting cable as a reference, the yellow wire is the outside one, and more documentation on the sensor is here. For the Ping sensor/Ultrasonic rangefinder Trig is on Digital Pin 13 and Echo is on Digital Pin 12 (in addition to power and ground of course).

5. The PmodBTN is wired to Analog Pin 0-4, along with ground and power.

Code

1. Download the 2.0_Code.

2. Activate the  FastLED and Keypad library (both found in the Arduino IDE library manager).

Keypad is not listed first when you search for it, you will have to scroll down until you find the one by Mark Stanley and Alexander Brevig.

3. Copy and paste the code into the Arduino IDE and click upload. Now it is time to play around with the board!

Note: Buttons 3 and 4 are attached to the ping sensor so try putting your hand over the sensor when you activate those visualizers.

Read through the code and our comments to see where you can make changes or add in new features. Have fun and feel free to expand this project to add more visualizers, sensors, ect!

More information

We updated the code and added more functionality, download LEDController_2 if you want the additional features. This code also requires the FastLED and KeypadUpload libraries.

In the new code the visualizers are:

  1. Flow
  2. Waterfall
  3. DoubleBounce
  4. Hand Bounce
  5. Levels
  6. Center Levels
  7. Blob
  8. AmbientSpots
  9. Segments
  10. Pulse

The numbers correspond to the visualizers and the letter to color palettes.

For the PmodBTN module, the effects are the following:

  • Top Right: Strobe
  • Bottom Right: Bounce Out (Double Bounce Single Sequence)
  • Bottom Left: Pause
  • Top Left: Not Set

Effects are temporary animation sequences that interrupt the current visualizer. They perform a single loop, then the current animation resumes. The one exception is the pause button, which requires you to unpause or skip out of it using a different effect.

Mechanical Design:

For our final version, we took a hollow wooden box from a local craft store and placed/traced out each component on the box. Then we dremeled a hole under the spot for the wires and set the Arduino inside the box. Finally, we mounted each piece with hot glue (after running the wires) and clipped the box shut with the metal clasp that came on it.

That’s it! Please let us know if you have any questions or issues and definitely share your creations with us!

Happy making!

Using Arduino for Citizen Science!

Science allows us to ask our most pressing questions and explore all sorts of curiosities. With some thought, hard work, and patience, we can use our explorations to build a better understanding and appreciation of the complex and beautiful world around us.

This tutorial will teach you how to use an Arduino (uno) microcontroller, how to use different types of sensors, and how to gather and visualize data. Along the way, we’ll build three projects: a tilt switch, a temperature and humidity sensor, and a light sensor!

Difficulty Level: Beginner

Read Time: 20 min

Build Time: Depends on your project! (Projects in this tutorial take about 15 – 20 min)

Pssst, What’s the Difference Between Citizen Science and “official Science”?

The biggest difference is that citizen science is, as I love to say, “hand wavy”, which means that there are lots of errors and uncertainties and no rigorous process to identify them. Because of this, conclusions reached through citizen science are much less accurate than science-science and should not be relied upon to make serious/life-altering/life-threatening claims or decisions.*

That being said, citizen science is a great way to build a fundamental understanding of all sorts of fascinating scientific phenomenon and is good enough for most day-to-day applications.

*If you are doing citizen science and you discover something potentially dangerous (e.g. high lead levels in water), inform your educator (if applicable) and contact the relevant authorities and professionals for assistance.

What Is Arduino??

Arduino is a microcontroller board and Integrated Development Environment (“IDE”), which is a fancy way of saying “coding program”. For beginners, I highly recommend Arduino Uno boards because they are super robust, reliable, and powerful.

Arduino boards are a good choice for citizen science projects because they have lots of input pins to read in both Analog and Digital sensors (we’ll get more into this later).

Of course, you can use other microcontrollers for citizen science depending on your (or your students’) needs, abilities, and comfort level. Here is an overview of microcontrollers to help ya decide what is best for you!

To flash, or program, an Arduino board, plug it in via USB, then:

1. Select the type of Arduino you’re using under Tools -> Boards.

 

2. Select the port (aka where it’s connected to your computer).

 

3. Click the Upload button and check that it finishes uploading.

Tools & Materials

If you’re just getting started, getting a kit is a quick & easy way to get a bunch of parts at once. The kit I’m using in this tutorial is the Elegoo Arduino Starter Kit.*

Tools

  • Arduino Uno
  • USB A to B cable (aka printer cable)
  • Jumper Wires
    • 3 male-to-male
    • 3 male-to-female
  • Breadboard
    • Optional but recommended to make your life easier and more fun 🙂

Materials

For the projects covered in this tutorial, you’ll need these parts from the Elegoo Arduino Starter Kit:

  • Tilt Switch
  • DTH11 Temperature and Humidity Sensor
  • LED
  • 100 Ohm Resistor

*Full disclosure: I purchase these same kits for workshops, but the kit used in this tutorial was donated by the lovely folks at Elegoo.

What Kinds of Sensors Can We Use?

When designing a science experiment, we typically start with a question: How much CO2 do plants absorb in a day? What is the impact force of a jump? What is consciousness??

Based on our question, we can then identify what we want to measure and do some research to figure out what sensor we can use to gather data (although it miiight be a bit tricky to gather data for that last question!).

When working with electronics, there are two main types of sensor data signals: Digital and Analog. In the photo, the first two rows of parts are all digital sensors, while the top two rows are analog.

There are many different types of digital sensors, and some are more challenging to work with than others. When doing research for your citizen science project, always check how the sensor puts out data (srsly tho) and make sure you can find an (Arduino) library for that specific sensor.

In the three projects covered in this tutorial we’ll use two types of digital sensors and one analog sensor. Let’s get a-learnin!

Digital Sensors!

Part 1: the Easy Ones

Most sensors you’ll use output a Digital Signal, which is a signal that is either on or off.* We use binary numbers to represent these two states: an On signal is given by a 1, or True, while Off is 0, or False. If we were to draw a picture of what a binary signal looks like, it would be a square wave like the one in the photo below!

There are some digital sensors, like switches, that are super easy and straightforward to measure because either the button is pushed and we get a signal (1), or it is not pushed and we have no signal (0). The sensors pictured in the bottom row of the first photo are all simple on/off types. The sensors on the top row are a bit more complex and are covered after our first project.

The first two projects in this tutorial will teach you how to use both types! Onward to build our first project!!

*On means an electrical signal in the form of electric current and voltage. Off means no electrical signal!

Project 1: Tilt Switch Digital Sensor

For this first project, let’s use a tilt switch, that black cylindrical sensor with two legs!
Step 1: Insert one leg of the tilt switch into Arduino Digital Pin 13, and the other leg into the GND pin right next to pin 13. Orientation doesn’t matter.

Step 2: Write a sketch that reads in and prints out the status of Digital Pin 13.

Or you can just use mine!

If you’re just getting started in coding, read through the comments to better understand how the sketch works and try changing some things to see what happens! It’s OK to break things, that’s a great way to learn! You can always re-download the file and start over 🙂

Step 3: To see your live data, click on the Serial Monitor button.

.. aaaand that’s it! You can now use the tilt switch to measure orientation! Set it up to call out your kitty when it knocks something over, or use it to keep track of how tree branches move during storms! .. & there are probably other applications in between those two extremes.

Digital Sensors!

Part 2: PWM and Serial Communication

There are many ways to create more complex digital signals! One method is called Pulse Width Modulation (“PWM”), which is a fancy way of saying a signal that is on for a certain amount of time and off for a certain amount of time. Servo motors (which can be used to measure position) and ultrasonic sensors are examples of sensors that use PWM signals.

There are also sensors that use serial communication to send data one bit, or binary digit, at a time. These sensors require some familiarity with reading datasheets and can be pretty tricky if you’re just getting started. Fortunately, common serial sensors will have code libraries* and sample programs to pull from so you can still cobble together something functional. More details on serial communication protocols is beyond the scope of this tutorial, but here is a great resource on serial communication from SparkFun to learn more!

For this sample project, let’s use the temperature and humidity sensor (DHT11)! This is a lil’ blue square with holes and 3 pins.

First we’ll need a couple of special libraries for the DHT11 sensor: the DHT11 library and the Adafruit Unified Sensor library.
To install these libraries (and most other Arduino libraries):

Step 1: Open up the Arduino library manager by going to Sketch -> Libraries -> manage Library

Step 2: Install and activate the DHT library by searching for “DHT” and then clicking Install for the “DHT Arduino Library” .

Step 3: Install and activate the Adafruit Unified Sensor library by searching for “Adafruit Unified Sensor” and clicking install.

Step 4: Insert the DHT library into your open sketch by going to Sketch -> Libraries, and clicking on the “DHT Arduino Library.  This will insert a couple of new lines at the top of your sketch, which means our library is now active and ready to use!

*Just like your fav local library, code libraries are a wealth of knowledge and other folks’ hard work that we can use to make our lives easier, yay!

Project 2: Temp and Humidity Digital Serial Sensor

 

Grab 3 male-to-female jumper wires from the Elegoo Arduino Starter Kit and we’re ready to go!

Step 1: With the header pins facing you, connect the rightmost header pin on the DHT11 to an Arduino ground (“GND”) pin.

 

Step 2: Connect the middle header pin to Arduino 5V output pin.

 

Step 3: Connect the leftmost header pin to Arduino Digital Pin 2.

Step 4: Finally, read the DHT library and try your hand at writing a sketch! Oooor you can use mine or the DHT test example sketch within Arduino -> Examples!

When you’ve got it up and running, go forth and measure the temperature and humidity of all the things! .. Like an animal’s breath, a greenhouse, or your favorite climbing spot at different times of the year to find the *perfect* sending temp.

Analog Sensors!

After the difficult dive into digital sensors, analog sensors can seem like a breeze! Analog signals are a continuous signal, like the photo below.

Most of the physical world exists in analog (e.g. temperature, age, pressure, etc.), but since computers are digital*, most sensors will output a digital signal. Some microcontrollers, like Arduino boards, can also read in analog signals**.

For most analog sensors, we give the sensor power, then read in the analog signal using the Analog Input pins. For this test, we’ll use an even simpler setup to measure the voltage across an LED when we shine a light on it.

*Computers use digital signals to store and transmit info. This is because digital signals are easier to detect and are more reliable, since all we’ve got to worry about is getting a signal or not versus having to worry about the quality/accuracy of the signal.

** To read in an analog signal on a digital device, we must use an Analog-to-Digital, or ADC, converter, which approximates the analog signal by comparing the input to a known voltage on the device, then counting how long it takes to reach the input voltage. For more info, this is a helpful site.

Project 3: LED As a Light Sensor!

Grab an LED (any color except white), a 100 Ohm resistor, and 2 jumper cables. Oh, and a breadboard!

Step 1: Insert the LED into the breadboard with the longer leg on the right side.

Step 2: Connect a jumper wire from Arduino Analog Pin A0 and the longer LED leg.

Step 3: Connect the resistor between the shorter LED leg and the breadboard negative power rail (next to the blue line).

Step 4: Connect the Arduino GND pin to the negative power rail on the breadboard.

Step 5: Write a sketch that reads in Analog Pin A0 and prints to the Serial Monitor!

Here is a sample code to get ya started.

Visualizing Data: Arduino IDE!

The Arduino IDE comes with built-in tools to visualize data. We’ve already explored the basics of the Serial Monitor which allows us to print sensor values. If you want to save and analyze your data, copy the output directly from the Serial Monitor and paste into a text editor, spreadsheet, or other data analysis tool.

The second tool we can use to see our data in the Arduino program is the Serial Plotter, a visual version (aka graph) of the Serial Monitor. To use the Serial Plotter, go to Tools –> Serial Plotter. The graph below is the output of the LED as a light sensor from Project 3!*

The plot will auto-scale and as long as you’re using Serial.println() for your sensors, it will also print all of your sensors in different colors. Hooray! That’s it!

*If you look at the end, there is a super interesting wave pattern which is likely due to the Alternating Current (“AC”) in our overhead lights!

Visualizing Data: Excel!

For more serious data analysis, there’s a super cool (and free!) add-in for Excel called Data Streamer*, which you can download here.

This add-in reads from the serial port, so we can use the exact same coding technique of printing data to serial to get data directly into Excel.. heck yes!!

How to use the Data Streamer Add-In:

1. Once you’ve installed it (or if you have O365), click on the Data Streamer tab (far right) in Excel.

2. Plug in your Arduino and click “Connect Device”, then select the Arduino from the drop-down menu.

3. Click “Start Data” to start data collection! You’ll see three new sheets open up: “Data In”, “Data Out”, and “Settings”.

Live data is printed in the Data In sheet.  Each row corresponds to a sensor reading, with the newest value printed in the last row.

By default we only get 15 rows of data, but you can change this by going to “Settings”. We can gather up to 500 rows (limit is due to Excel bandwidth — there’s a lot happening in the background!).

 

4. Add a Plot of your data! Do some data analysis!
Scatter plots show you how the sensor readings change over time, which is the same thing we saw in the Arduino Serial Plotter.

To add a Scatter Plot:

Go to Insert -> Charts -> Scatter. When the plot pops up, right click on it and choose “Select Data”, then Add. We want our data displayed on the y-axis, with “time”** on the x-axis.

To do this, click the arrow next to the y-axis, go to the Data In sheet, and select all of the incoming sensor data.

We can also do calculations and comparisons in Excel! To write a formula, click on an empty cell and type an equals sign (“=”), then the calculation you want to do. There are lots of built-in commands like average, maximum, and minimum.

To use a command, type the equals sign, the command name, and an open parenthesis, then select the data you’re analyzing and close the parentheses.

5. To send more than one column of data (AKA more than one sensor), print the values on the same line separated by a comma, with a final blank new line, like this:

Serial.print(sensorReading1); 
Serial.print(","); 
Serial.print(sensorReading2); 
Serial.print(","); 
Serial.println();

*Full disclosure: Although this tutorial is not affiliated, I do work w/ the Microsoft Hacking STEM team which developed this add-in.

**If you want the actual time to be on the x-axis, select the timestamp in Column A on the Data In sheet for the x-axis values in your Scatter Plot. Either way, we’ll see our data as it changes over time.

Go Forth and Measure All the Things!!

Alright folks, that’s all! Time to go outward and upward! Use this as a foundation to start exploring sensors, Arduino coding, and data analysis to tackle your questions, curiosities, and fav mysteries in this big, beautiful world.

Remember: there are lots of folks out there to help you along the way, so please leave a comment if you have a question!

Need some more ideas? Here’s how to make a wearable state change switch, a solar-powered remote temperature sensor, and an Internet-connected industrial scale!

Like this tutorial and want to see more? Support our projects on Patreon! 😀

Make a Sneaky Wearable ‘State Change Switch’!

 

Secretly change settings for your wearable outfits or use this button as a secret prank trigger! Here’s a quick & easy tutorial on how to build and program a “state change switch.” AKA a button that cycles through different settings. It’s super easy and has tons of practical applications!

Read Time: ~ 5 min
Build Time: ~ 30 min
Cost: Super cheap (>$5)

Materials!

materials1-sm

— Glove (just one.. but you should probably wear two to avoid giving away the secret)

— Three (3) stranded wire segments (24/26 gauge), approx. 3 ft

Wires should be long enough to reach from your palm to wherever you want to hide the electronics. I hid mine in a belt pouch, but you could also opt for a pocket, backpack, etc.

— One (1) 10kOhm resistor

— One (1) pushbutton (aka momentary switch)

— One (1) 1″ x 1″ piece of thin wood

Those free wood swatches at hardware stores are perfect!

— Microcontroller

I used the SparkFun EL Sequencer b/c I was using this switch to select different settings for my Hallowen EL Wire costume. Check out the tutorial to learn how to build your own version of this costume, or you can use this state change switch with any ol’ microcontroller for your own awesome project!

 

Build it!

schematic_bb

buttonbase1-sm

1. Drill holes in a small piece of wood for the button feet.

resistor1-sm

2. Solder a wire to one of the button legs, and a resistor to the other button leg on the same side. Solder a black wire to the resistor.

3. On the other side of the button, solder a wire to the leg across from the resistor.

4. Test electrical connections, then coat all solder joints in hot glue.

buttonbase-bottom2-sm

5. Connect the black wire to the microcontroller ground, and the wire on the same side to the microcontroller voltage output (Vcc).

6. Connect the wire on the other side to a microcontroller digital (or analog) input pin (see schematic above), and then onward to programming!

buttonbase-solder-sm

 

Program it!

code-screenshot

Most folks that program state change switches use the modular, or mod, operator* to tell different settings apart. It’s not perfect, but for how little code is involved it’s a good way to cycle through different settings and get back to our original state.

Here’s a quick sketch that will allow you switch between three different settings by pushing the button. As is, it’s written to switch between three different digital output settings. In other words, if you have a motor connected to your microcontroller, the button will switch the motor from constantly on, to pulsing (i.e. repeatedly on/off), to constantly off, then back to constantly on.

*The mod operator (usually “%”) divides the number by the value after the operator and gives you the remainder. For example, if you see: 10%2, it means 10 / 2 = 5, which equals 0, since there is no remainder. Another example is 10%3, which equals 1, since 10 / 3 = 3.33, and 0.33 is one out of three. Here’s more info on this or feel free to leave a comment if you have any questions!

 

Finish & Test!

Connect the button wire leads to your microcontroller inputs, run the full program and test to see that it works as expected. If it’s all good, put the glove on and push the state change switch and watch as your costume/insertotherawesomeprojecthere changes through different settings!

Now go forth and show off your project around town!