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!

Raspberry Pi Impact Force Monitor

How much impact can the human body handle? Whether it’s football, rock climbing, or a bicycle accident, knowing when to seek immediate medical attention after a collision is incredibly important, especially if there are no obvious signs of trauma. This tutorial will teach you how to build your very own impact force monitor!

 

Read Time: ~15 min

Build Time: ~60-90 min

This open-source project uses a Raspberry Pi Zero W and an LIS331 accelerometer to monitor and alert the user of potentially dangerous G-forces. Of course, feel free to modify and adapt the system to suit your various citizen science needs.

Note: Build fun stuff with the Impact Force Monitor! However, please don’t use it as a substitute for professional medical advice and diagnosis. If you feel that you have taken a serious fall, please visit a qualified and licensed professional for proper treatment.

Suggested Reading

To keep this tutorial short n’ sweet (er, well, as much as possible), I’m assuming you’re starting with a functional Pi Zero W. Need some help? No problem! Here’s a full setup tutorial.

We’ll also be connecting to the Pi remotely (aka wirelessly). For a more thorough overview on this process check out this tutorial.

**Stuck or want to learn more? Here are some handy resources:**

1. Excellent “Getting Started” guide for the Pi.

2. Full hookup guide for the LIS331 accelerometer breakout board.

3. More about accelerometers!

4. Overview of the Raspberry Pi GPIO pins.

5. Using the SPI and I2C Serial buses on the Pi.

6. LIS331 Datasheet

Materials

 

Tools

  • Soldering Iron & accessories
  • Epoxy (or other permanent, non-conductive liquid adhesive)
  • Probably also scissors 🙂

But wait! What is Impact Force?

Fortunately the term “impact force” is pretty straightforward: the amount of force in an impact. Like most things though, measuring it requires a more precise definition. The equation for impact force is:

F = KE/d

where F is the impact force, KE is the kinetic energy (energy of motion), and d is the impact distance, or how much the object crunches. There are two key takeaways from this equation:

1. Impact force is directly proportional to the kinetic energy, meaning that the impact force increases if the kinetic energy increases.

2. Impact force is inversely proportional to impact distance, meaning that the impact force decreases if the impact distance increases. (This is why we have airbags: to increase the distance of our impact.)

Force is typically measured in Newtons (N), but impact force may be discussed in terms of a “G-Force”, a number expressed as a multiple of g, or earth’s gravitational acceleration (9.8 m/s^2). When we use units of G-force, we are measuring an objects acceleration relative to free fall towards the earth.

Technically speaking, g is an acceleration, not a force, but it is useful when talking about collisions because acceleration* is what damages the human body.

For this project, we’ll use G-force units to determine if an impact is potentially dangerous and deserving of medical attention. Research has found that g-forces above 9G can be fatal to most humans (without special training), and 4-6G can be dangerous if sustained for more than a few seconds.

Knowing this, we can program our impact force monitor to alert us if our accelerometer measures a G-force above either of these thresholds. Hooray, science!

For more information, read about impact force and g-force on Wikipedia!

Acceleration is a change in speed and/or direction.

Configure the Pi Zero W

Gather your Raspberry Pi Zero and peripherals to configure the Pi to be headless!

  • Connect the Pi to a monitor and associated peripherals (keyboard, mouse), plug in the power supply, and log in.
  • Update software to keep your Pi speedy & secure. Open the terminal window and type these commands:
    • Type and enter:
sudo apt-get update
  • Type and enter:
sudo apt-get upgrade
  • Reset:
sudo shutdown -r now

Enable WiFi & I2C

  • Click the WiFi icon on the upper right corner of the desktop and connect to your WiFi network.
  • In the terminal type this command to bring up the Pi’s Software Configuration Tool:
sudo raspi-config
  • Select “Interfacing Options”, then “SSH”, and choose “Yes” at the bottom to enable.

  • Go back to “Interfacing Options”, then “I2C”, and select “Yes” to enable.
  • In the terminal, install remote desktop connection software:
sudo apt-get install xrdp

  • Type ‘Y’ (yes) on your keyboard to both prompts.
  • Find the Pi’s IP address by hovering over the WiFi connection (you might also want to write it down).

  • Change the Pi’s password with the passwd command.

Restart the Pi and Log in Remotely

We can now ditch the HDMI and peripherals, woohoo!

  • Setup a remote desktop connection.
    • On a PC, open Remote Desktop Connection (or PuTTY if you’re comfy with that).
    • For Mac/Linux, you can install this program or use a VNC program.
  • Enter the IP for the Pi and click “Connect” (Ignore warnings about unknown device).
  • Log in to the Pi using your credentials and away we go!

Build It! Electronics

Here’s the electrical schematic for this project:

Note: The LIS331 breakout board in the schematic is an older version — use the pin labels for guidance

And here’s the pinout for the Pi Zero:

Connect the Accelerometer to the Pi’s GPIO

  • Solder and carefully remove any flux residue on the accelerometer and Pi GPIO’s header pins.

  • Then connect jumper wires between the LIS331 breakout board and Pi between the following pins:

LIS331 Breakout Board                     Raspberry Pi GPIO Pin

GND                                                 GPIO 9 (GND)

VCC                                                  GPIO 1 (3.3V)

SDA                                                   GPIO 3 (SDA)

SCL                                                   GPIO 5 (SCL)

  • To make it easier to connect the sensor to the Pi Zero, a custom adapter was made by using a female header and jumper wires. Heat shrink was added after testing the connections.

Add an Alert LED!

  • Solder a current limiting resistor to the negative LED leg (shorter leg) and add shrink wrap (or electrical tape) for insulation.

  • Use two jumper cables or header pins to connect the positive LED leg to GPIO26 and the resistor to GND (header positions 37 and 39, respectively).

Completed Electronics Setup

Connect the battery pack to the Pi’s input power to complete the setup!

Program It!

The Python code for this project is open-source! Here’s a link to the GitHub repository.

For Folks New to Programming:

  • Read through the program code and comments. Things that are easy to modify are in the “User Parameters” section at the top.

For Folks More Comfortable w/ the Technical ‘Deets:

  • This program initializes the LIS331 accelerometer with default settings, including normal power mode and 50Hz data rate. Read through the LIS331 datasheet and modify initialization settings as desired.

All:

  • The maximum acceleration scale used in this project is 24G, because impact force gets big real quick!
  • It is recommended to comment out the acceleration print statements in the main function when you are ready for full deployment.

Before you run the program, double check that the accelerometer address is 0x19. Open the terminal window and install some helpful tools with this command:

sudo apt-get install -y i2c-tools

Then run the i2cdetect program:

i2cdetect -y 1

You’ll see a table of I2C addresses displayed as shown in the image above. Assuming this is the only I2C device connected, the number you see (in this case: 19) is the accelerometer address! If you see a different number, take note and change in the program (variable addr).

Quick Overview of Program

The program reads the x, y, and z acceleration, calculates a g-force, and then saves the data in two files (in the same folder as the program code) as appropriate:

  • AllSensorData.txt – gives a timestamp followed by the g-force in the x, y, and z axes.
  • AlertData.txt – same as above but only for readings that are above our safety thresholds (absolute threshold of 9G or 4G for more than 3 seconds).

G-forces above our safety thresholds will also turn on our alert LED and keep it on until we restart the program. Stop the program by typing “CTRL+c” (keyboard interrupt) in the command terminal.

Here’s what both data files look like:

Test the System!

Open the terminal window, navigate to the folder where you saved the program code using the cd command.

cd path/to/folder

Run the program using root privileges:

sudo python NameOfFile.py

Check that the acceleration values in the x, y, and z-direction are printing to the terminal window, are reasonable, and turn on the LED light if the g-force is above our thresholds.

  • To test, rotate the accelerometer so that the each axes point towards the earth and check that the measured values are either 1 or -1 (corresponds to acceleration due to gravity).
  • Shake the accelerometer to make sure the readings increase (sign indicates direction of axis, we’re most interested in the magnitude of the reading).

Secure Electrical Connections & Install It!

Once everything is working correctly, let’s make sure the impact force monitor can actually withstand impact!

  • Use heat shrink tube and/or coat the electrical connections for the accelerometer and LED in epoxy.
  • For super durable, permanent installations, consider coating the whole shebang in epoxy: the Pi Zero, the LED, and the accelerometer (but NOT the Pi cable connectors or the SD card).
    • Warning! You can still access the Pi and do all the computer stuff, but a full coat of epoxy will prevent the use of the GPIO pins for future projects. Alternatively, you can make or purchase a custom case for the Pi Zero, although check for durability.

Secure to a helmet, your person, or a mode of transportation like your skateboard, bicycle, or cat*!

Fully test that the Pi is securely fastened or the GPIO pins may become loose causing the program to crash.

*Note: I originally meant to type “car”, but figured an impact force monitor for a cat might also yield some interesting data (with kitty’s consent, of course).

Embedding the Circuit in a Helmet

Theres a few methods of embedding the circuit into a helmet. Here’s my approach to a helmet installation:

  • If you have not already, connect battery to Pi (with battery off). Secure the accelerometer to the back of the Pi with nonconductive insulation in between (like bubble wrap or thin packing foam).

  • Measure the dimensions of the Pi Zero, accelerometer, LED, and battery connector combination. Add 10% on either side.

  • Draw a cutout for the project on one side of the helmet, with the battery connector facing towards the top of the helmet. Cut out the padding in the helmet leaving a few millimeters (~ 1/8 in.).

  • Place the sensor, Pi, and LED in the cutout. Cut pieces of the excess helmet padding or use packaging foam to insulate, protect, and hold the electronics in place.

  • Measure the battery’s dimensions, add 10%, and follow the same cutout for the battery. Insert the battery into the pocket.

  • Repeat the insulation technique for the battery on the other side of the helmet.

  • Hold the helmet padding in place with tape (your head will keep it all in place when you are wearing it).

Deploy!

Power up the battery pack!

Now you can remotely log into the Pi through SSH or remote desktop and run the program via the terminal. Once the program is running, it starts recording data.

When you disconnect from your home WiFi, the SSH connection will break, but the program should still log data. Consider connecting the Pi to your smartphone hotspot WiFi, or just log back in and grab the data when you get home.

To access the data, remotely log into the Pi and read the text files. The current program will always append data to the existing files – if you want to delete data (like from testing), delete the text file (via the desktop or use the rm command in the terminal) or create a new file name in the program code (in User Parameters).

If the LED is on, restarting the program will turn it off.

Now go forth, have fun in life, and check on the data every so often if you happen to bump into something. Hopefully, it’s a small bump but at least you’ll know!

Adding More Features

Looking for improvements to the impact force monitor? It is outside the scope of the tutorial but try looking at the list below for ideas!

Do some analysis on your g-force data in Python!

The Pi Zero has Bluetooth and WiFi capabilities – write an App to send the accelerometer data to your smartphone! To get you started, here’s a tutorial for a Pi Twitter Monitor.

Add in other sensors, like a temperature sensor or a microphone*!

Happy Building!

*Note: To hear the whooshing sounds associated with your acceleration! 😀

Make a Minecraft Gesture Controller!

Move your body to play Minecraft! What!! Yes. Check the video for a demo 🙂

This tutorial will show you how to make your very own gesture game controller for Minecraft (or your other fav. computer game). Move your hand(s) to walk/run/jump, look around, and attack* all the things!

Let’s get started! Grab yourself a Circuit Playground Expresssnag my program code, and get shakin’ to play Minecraft in (srsly) the most fun way ever! 😀

Read time: 20 min

Build Time: ~ 2 hours

Cost: ~$30

*It is a biiiiit tricky to attack moving things (like monsters), so be careful in survival mode! Or use this to challenge your skills 🙂

Materials

Tools

  • Sewing Needle
  • Scissors
  • and a lil’ patience.. 🙂

 

Build the Glove Controller!

You can make the gesture controller without the glove, but the glove controller makes it easier to play, keeps the CPX in the same orientation (very important), and means you can use your fingers as added controls!

1. Cut rectangles of conductive fabric for the finger pads (~ 0.5 in. x 1 in.).

2. Use regular thread to sew the conductive fabric pads onto each of the glove fingers.

Suggested to use a highlighter or other pen to avoid sewing the two sides of the glove together (learn from my mistakes bbies).

3. Attach CPX to the glove with velcro squares.

4. Use an alligator clip or insulated wire to connect the CPX ground (“GND”) to the thumb pad.

5. Stitch conductive thread from the CPX capacitive touch pads (A1, A2, A3 & A4) to each of the four fingers.

6. If you have a multimeter, check continuity between the CPX pins and the conductive thread pads.

Plan out your controller!

 

First! What do we need to do to control Minecraft (or another awesome game)?

This is a super helpful & fun lesson in Design Thinking, but you can skip this if you want to just use my controls. You can always come back here later if you want to make changes later 😀

1. Determine (crucial) game controls.

Note: Start simple! Figure out the most important controls for the game and start there. You can always add more later.

Here are the controls that I wanted to use while playing Minecraft.. in creative mode 🙂 (you can use the same ones or customize your own controller!):

Movement:

  • Walk forward: W key
  • Run: Ctrl + W
  • Jump: Space bar
  • Look Left & Right: Mouse rotate
  • Walk backward: S key

Actions:

  • Attack: Mouse Left Click
  • Place Block/Push/Open: Mouse Right Click
  • Inventory: E key
  • Escape: ESC key

2. Decide how you want to use gestures and/or the finger pads to trigger these controls. Recommended to sketch out your plan.

Here is my design thought process:

I’ve always wanted to feel like I was actually *in* a game, so I went the “cheap VR” route and used gestures to control basic movements. For walking, I went the “let’s move my arms like I’m walking” route, which easily transitioned into running and jumping by increasing the speed of motion.

To make it easy to place a block or exchange items, I decided to use an “awkward handshake” motion.

Turning was a bit of a challenge, but my goal was to be able to look around by moving my hands in the direction I wanted to look.

Attack became the pointer finger pad, inventory the middle finger pad (which I ended up removing), Escape the ring finger pad, and the pinky finger pad to let me to walk backwards.

Again, you can keep these same controls or design your own 😀

Let’s get programming: Set up the CPX!

1. If you’re using Windows, download the Adafruit Windows Drivers here.

2. Download & save the latest CPX Circuit Python UF2 file.

3. Plug in the CPX with a USB cable (make sure it has data transfer capabilities).

4. Double-click the reset button on the CPX.

The LEDs should turn green. If they are red, it means something is wrong with data transfer to the CPX — check the USB cable, try another USB port on your computer, or try the trusty “unplug and plug back in” method.

5. On your computer, you will see a new disk drive called “CPLAYBOOT”.

6. Drag the CPX Circuit Python UF2 file onto the disk drive.

7. The “CPLAYBOOT” drive will disappear and be replaced with “CIRCUITPY”.

 

Add all the libraries!

Libraries let us access all sorts of special functions for the CPX without having to do a ton of programming.. hooray for open-source! This install will download most of the standard Circuit Python libraries* so peruse them at your leisure to learn about more cool things you can do!

1. Download and save the Adafruit Circuit Python Library Bundle Release from here.

2. Unzip the folder, open the first folder, and copy the “lib” folder onto the “CIRCUITPY” drive.

*It is unlikely that you’ll run out of space since the CPX comes with at least 2MB of Flash storage. But, if you do end up needing more space, you can revisit the libraries and remove the ones you don’t need. If you mess ’em up, just copy and paste the lib folder again.

 

Writing the Controller Code

The CPX has an on-board compiler, which means you can program it in (pretty much) any language you want! I opted for MicroPython, a version of Python for microcontrollers, ’cause Python is awesome.

Read this step if you want to understand how the program works (definitely suggested) or if you want to modify the code.

Here’s the GitHub repository that has the full code.Download it, drag it to your CPX, and rename the file “Code.py” (here’s the raw code if you want to just copy & paste).

1. To do the things I mentioned in the last step in MicroPython, we need the following libraries:

  • LIS3DH accelerometer

    • This allows us to use motion to trigger various things.
  • Human Interface Device (“HID”) keyboard

    • This library allows us to control the keyboard!
  • HID mouse

    • This library means we can control the mouse!
  • CPX capacitive touch
    • This library lets us use the capacitive touch feature on the CPX, hooray!
  • A couple of other libraries to make our lives easier: timebusio, and board.

2. Configure and initialize the libraries.

Assign variables for the keyboard, mouse, and accelerometer objects. Select a range for the accelerometer.

3. Write short functions for each of the controls.

The motion controls can be tricky. Do some initial testing with the accelerometer by printing the values in a serial monitor (in the source code, go to the __main__ function and uncomment the two debugging lines). This will help you to determine thresholds for walking, running and jumping, looking left and right, and placing objects.

The touch pad triggers are much easier as you are only looking for a capacitive trigger (True/False).

Remember to release all of the keyboard and mouse keys at the end of each function!

Debugging: Seeing what’s up the CPX program

If you’re familiar with Arduino, you’re probably familiar with the Serial Monitor. The CPX has the same feature with a slightly different access point depending on what program you are using.

If you are using Mu it’s super easy: the serial console is built in and will automatically detect your board, yay!.

If you are using Idle or another program, follow these steps:

1. Download PuTTY* here.

2. Go to Windows Device Manager and check the serial port number for the CPX (e.g. COM18) — see Photo below.

If there are multiple serial ports listed, unplug the CPX and plug it back in to see which one disappears then reappears.

3. Open PuTTY and select “Serial”.

4. Enter the serial port number (e.g. COM18) under “Serial line” and the baud rate of 115200 under “Speed”.

5. Click Connect! 

*PuTTY is a free and open-source SSH and telnet connection program.

 

Test & Improve

Load the program onto the CPX by dragging and dropping the python file onto the CIRCUITPY drive, then rename the file as “Code.py”

Like pretty much every project, this one will likely be a little wonky when you first get it running. If the touch pads are acting strange, reset the CPX (this recalibrates the capacitive input pins).

Test 1:

– Open up the serial monitor with PuTTY and run the program (CTRL + D)

– Test each of the movement controls (you’ll see the mouse moving on the screen and make sure the program doesn’t crash as well as the touch pads (which should display relevant text on the serial monitor).

Test 2:

Deploy in Minecraft creative mode! Test the movement and action controls to see if anything breaks or doesn’t work as expected (plz keep in mind that this is a prototype)

Update the program based on your testing. Remember, it’s OK if it’s not perfect, there’s always time to make it better!

 

Have all the fun!!

You’re ready to run through Minecraft!! Just be wary of monsters, it might be a bit tricky to protect yourself..

Supplementing your gesture controller with a keyboard is a good idea if you want play for reals 🙂

Please like and/or leave a comment if you enjoyed the tutorial! And of course, let me know if you have any comments or questions!
Happy Building!

<3, jenfoxbot

Intro to the (Headless) Raspberry Pi!

Finally! Use your Raspberry Pi without spending what feels like forever connecting external peripherals and dealing w/ a cable monstrosity: Configure your Pi to be headless! (not the scary kind tho) This is particularly helpful for folks teaching workshops with the Raspberry Pi, since it can be cumbersome (and expensive) to provide monitors, keyboards, and mice for every student.

I’m assuming that y’all know a bit about the Pi, so this tutorial will not cover what the Pi is or it’s awesome capabilities (I’m lookin’ at you, GPIO pins!). To learn more about what the Pi can do, check out some of my other tutorials (see the last section in this tutorial) or leave a comment.

What is covered in this tutorial: Enabling and using SSH, a general overview of the Linux terminal window, and how to connect to the Pi’s GUI (Graphical User Interface, aka the Desktop view) via SSH.

Read Time: 15 min

Build Time: ~20 min

Cost: Free! (assuming you already have an RPi and Ethernet cable)

Materials

Computer with Ethernet port & SD Card slot

– Raspberry Pi 3

– SD Card (8GB or larger)

– MicroUSB to USB power cord

– Ethernet Cable

– RecommendedRaspberry Pi Case & GPIO cable

Software

For this project, you’ll need the following (free!) software programs:

 

Configure the SD Card

1. Download your favorite flavor of Raspbian! You can get the most recent version here.

2. Insert your SD card and open Etcher.

3. Select the Raspbian zip file, the driver for your SD card, and click “format”.

4. Enable SSH access

Open the file contents for the SD card. Add a new text file titled “SSH”. If the computer adds a file extension (e.g. “.txt”), delete it and ignore any warnings.

5. Eject the SD card and insert it into your Pi.

 

Let’s Get Connected!

1. Plug in the Ethernet cable between the Raspberry Pi & your computer.

2. Plug in the USB power cable.

Check that the red power light turns on and that the Ethernet port lights (yellow & green) are on and/or blinking.

3. Connect the RPi to the World Wide Web (aka the Internet).

Go to Settings -> Network & Internet -> Change Adapter Options (aka Network Connections).

Click on the Ethernet connection, hold down “CTRL”, and then click on your WiFi connection.* Right-click in the window and select “Bridge Connections” — this will bridge the connection between the Ethernet port to your WiFi port.

*If you select the WiFi connection first, it will bridge the connection from the WiFi to the Ethernet, which would allow you to log into the Pi but not connect to the Internet.

4. Open PuTTY and log in to the Pi using the “raspberrypi.local” IP address.

Default username: pi

Default password: raspberry

5. Change the default password by typing passwd and following the prompts.

 

Navigating the Linux Terminal Window (Shell)

The terminal window is the control panel for the system.

It typically shows a command prompt, which gives us information but is not part of the commands to the system. Most commonly the command prompt displays the user’s login name and the current working directory (represented by a twiddle: ~ ).

Inputting Commands

Commands are written after the prompt and inputted by pressing the Enter key.

Commands can be issued as-is or followed by one or more options. Options usually have a dash in front of them, like the following:

ls -a

You can view the options for a specific command by typing the command name followed by “–help” (will cover this more later).

 

 

 

 

 

 

 

 

Linux Hot Keys!

There are a handful of special key combinations that make navigating the terminal window easier and faster. Here are a some of the most common ones:

  • Ctrl+A – Move cursor to beginning of command line
  • Ctrl+E – Move cursor to end of command line
  • Ctrl+C – End running program
  • Ctrl+D – Logout of current session
  • Ctrl+R – Search command history
  • Ctrl+Z – Suspend a program

 

  • Left and Right arrow keys – Move cursor one place to the left or right on command line
  • Up and Down arrow keys – Browse command history
  • Shift+PageUp and Shift+PageDown – Browse terminal buffer (to see text that is off screen)
  • Tab – Command or filename completion
  • Tab Tab – Shows file or command completion options

Practice using these every time you are in the terminal window and you’ll quickly become a Linux wizard!

Getting Help in the Terminal

1. Manual and Information Pages

The manual pages are an exhaustive resource for all of the available commands in the Linux terminal window. To read the manual pages on a particular command, type the following:

man command

This will pull up the manual pages for the particular command that you are searching. Here’s the manual pages for the apropos command:

In the manual, the first line contains the name of the command you are reading about and the ID of the section that contains the manual page.

After the first line is a synopsis, which is a short description of the command that includes technical notation of all the options and/or arguments. Options are a way of executing the command, and an argument is what you execute it on. Optional arguments are put between square brackets.

After the synopsis is a longer description of the command, followed by a more in-depth overview of the available options, information about combining options, other related commands, and other information pertaining to the command.

Some commands have multiple man pages, like the “passwd” command. To see all pages about a command, use the “-a” option:

man -a passwd

The info pages contain more recent information and can be easier to use. Here’s what the menu of the info pages looks like:

To view the info pages on a command (replacing “command” with the actual name of the command you want to research, like “apropos”), type the following:

info command

To navigate the info pages, use the arrow keys to browse through text, the Enter key to read about a particular keyword, “P” and “N” keys to go to the previous or next subject, and the space bar to move one page further. Use “Q” to quit.

2. whatis and apropos commands

The whatis command gives brief information about a command and lists the first section in the man pages that contains a relevant page (in parenthesis after the command name).

If you’re entirely unsure where to start, the apropos command is a good way to search for keywords. For example, if you want to know how to start a browser, you can type apropos browser, which will pull up a list of all browser-related programs, including web browsers, file and FTP browsers, etc.

Here’s the apropos search results for “text”, which displays commands and programs that contain the phrase “text”:

 

3. Using the –help option

Most commands also have the option –help, which gives a short explanation of the command and a list of available options. When in doubt, this is a great way to get some quick and useful information on using a particular command and its possible extensions.

To use the –help option, type –help after a particular command, like the following example (also shown in the photo above):

apropos --help

The output looks like this:

 

Enough of the Terminal Window! Where’s the friggin’ Desktop??

Alright alright.. Remote Desktop Connection is an easy way to use the desktop view, also known as “Graphical User Interface,” or GUI for short.

1. Install Remote Desktop Connection on your Pi:

sudo apt-get install xrdp

2. Install Remote Desktop Connection on your PC (is already installed on Windows OS).

3. Open Remote Desktop Connection and log in using the “raspberrypi.local” IP (or find your Pi’s IP using command ifconfig). Ignore warning (click “yes”).

4. Log in with the Pi’s username and password.

If you haven’t changed your password yet, do so now. (Yes, I know I already told ya to do so but it is worth repeating since someone could actually hack into your Pi if you don’t change the default password.)

Now you can use the Pi’s GUI and do almost* everything via your PC!

*Sadly, we can’t play Minecraft in this mode as it uses too much data to be transferred via SSH. Using a VNC viewer is one option around this if you really want to play Minecraft remotely.

What is SSH, anyway?

SSH stands for “Secure SHell” — it is a “cryptographic network protocol for operating network services securely over an unsecured network.” – Wikipedia

… Uh, what?

In other words, SSH is a secure way to connect between one computer and another, even if the network through which you are connected is not secure.

For example, if you are on a shared network and you use SSH to remotely log into another computer, other folks on the shared network can’t see what you’re doing through the remote connection (although Snowden did release documents that showed the NSA can sometimes decrypt SSH).

Common uses of SSH include remote log in, like if you want to connect to a computer that lives a mile underground without having to, you know, actually go down there. (I used to work for a super cool dark matter experiment called DRIFT and this is how we would access the computers that controlled the detector because the computers lived in a mine about 3 miles underground.. too far to travel to update software!).

Here’s the full Wikipedia page on SSH — it’s super cool so check it out!

More to Explore!

Go forth and explore! Practice using the terminal window until you get comfortable and familiar with the basic commands.

Program the GPIO pins to do cool stuff! Need some ideas? Check out these tutorials:

1. Making a Soil Moisture Sensor

2. Building an Irrigation Controller (can be paried w/ Soil Moisture Sensor)

3. Bark Back: Install an IoT Pet Monitor

4. Expand on your Smart Home & add a Motion Triggered Music Player

Need parts?

Take apart old & broken electronics! Electronic toys are a great place to get motors and speakers. If you want better motors, take apart power tools.

Ask friends or find a repair shop for extra parts and wire, save power cables from old electronics and use them as power supplies or harvest them for wires and/or connectors, save old headphones and use them for audio projects.

Best piece of advice: think before you toss 🙂



			

IoT Pet Monitor!

Keep an eye (er, ear) on your beloved bbies while you are away! This project monitors the volume of sound in your home and if your pet gets too anxious and starts barking or making other loud noises, soothe their sad lil’ soul by turning on music or your own (pre-recorded) voice!

This tutorial will show how to build this project using a Raspberry Pi computer to monitor sound in your home (via the Cloud) to see if and when your pet is upset.

Along with the Pi (and speakers), we’ll use the SparkFun MEMS microphone breakout board to measure volume levels and trigger the audio player. Data is uploaded to the CloudMQTT service using the MQTT communication protocol.

Total Read Time: 8 min.

Total Build Time: 60 min. (less if you are experienced)

Suggested Reading

To build this project, you’ll need a fully configured, WiFi-connected Raspberry Pi 3 computer with ​Raspbian OS. It’s also helpful to know some ​Python programming as well as the following things: (1) how to use and control the Raspberry Pi GPIO pins; (2) MQTT communication; and (3) analog sensors. If any of this is unfamiliar, or if you’re just curious (be curious!), check out the tutorials below!

Raspberry Pi 3

  1. ​Raspberry Pi 3 Starter Kit Hookup Guide
  2. ​Raspberry Pi GPIO
  3. ​SPI Communication with the Raspberry Pi

MQTT Communication Protocol

MQTT (Message Query Telemetry Transport) is a popular IoT communication protocol. We’ll use the Paho Client Python library and an MQTT service called ​CloudMQTT. Here’s more about MQTT and how to use it:

  1. Exploring Communication Protocols for IoT
  2. Getting Started with CloudMQTT
  3. ​Overview of Eclipse Paho MQTT Python client library

MEMS Microphone Breakout Board

The MEMS microphone is an analog microphone, so we’ll need an Analog-to-Digital converter (“ADC”) to read in the analog signal with the Raspberry Pi digital GPIO pins.

  1. Getting started with the SparkFun MEMS Microphone Breakout Board
  2. ​MEMS Microphone Datasheet
  3. MCP3002 ADC Datasheet

 

Materials

Raspberry Pi 3 Model B

We’ll also need the following peripherals: ​Raspberry Pi 3 Case​SD Card (minimum 8 GB); ​Raspberry Pi 3 GPIO cable; ​MicroUSB power cable; HDMI cable and ​HDMI-compatible monitor; USB keyboard; USB mouse; speakers with 1/8″ headphone port.

​SparkFun MEMS Mic Breakout Board

​MCP3002 (Analog-to-Digital Converter)

​Breadboard & ​M-to-M Breadboard Jumper Wires

 

Configure the Raspberry Pi

Step 1: Check & Install Updates
Checking for and installing updates is always a good way to start. Run the following commands in the terminal window:

    sudo apt-get update
    sudo apt-get upgrade
    sudo reboot

Step 2: Set up SPI Interface for MEMS Microphone + MCP3002

To use the SPI (Serial Port Interface) to read in the MEMS Microphone via the MCP3002, we’ll need the Python Dev Package:

    sudo apt-get install python-dev

We’ll also need the SPI Interface (may want to create a subfolder to save this in):

    git clone git://github.com/doceme/py-spidev
    sudo python setup.py install

Here’s the SPI-Dev Documentation if you run into any issues.

Step 3: Playing Sounds with OMXPlayer

The OMXPlayer is an audio and video player pre-loaded on Raspbian OS. It works with most sound file types, including: .wav, .mp3, and .m4a. This is what we’ll use to play back sounds when Fido gets too loud. The Python library to control the OMXPlayer is included in Raspbian (woo!).

To test the OMXPlayer from the terminal, type the following:

    omxplayer /home/.../SongFilePath/SongFileName.mp3

If that doesn’t work, try forcing it over the local audio-out device:

    omxplayer -o local /home/.../SongFilePath/SongFileName.mp3

Step 4: Configure CloudMQTT Server

Now we set up an MQTT server! To do this using CloudMQTT, do the following:

  1. Set up a CloudMQTT account (the “Cute Cat” plan is free).
  2. Create a new MyCloud instance.
  3. In the Console, create a new ACL rule.
  4. You can monitor published messages in the “Websocket” UI.

 

Finally, install the MQTT Paho Client Python library:

    pip install paho-mqtt


Build it! Hardware

Here’s a pinout for the Raspberry Pi 3:

1. Insert MCP3002 pins into breadboard. Here’s a pinout for this board:

The MCP3002 uses 4 SPI pins for communication: Serial Clock (“SCL”), Master Input Slave Output (“MISO”), Master Output Slave Input (“MOSI”), and Chip Select (“CS”). These pins correspond to Raspberry Pi GPIO pin 11 (SCLK), GPIO pin 9 (MISO), GPIO Pin 10 (MOSI), and GPIO Pin 8 (CE0).

Make the following connections with MCP3002 pins:

  • ​Connect Pin 1 to Raspberry Pi GPIO Pin 8 (CE0)
  • Connect Pin 2 to the analog output of the MEMS Microphone breakout board
  • Connect Pin 4 to GND
  • Connect Pin 5 to Raspberry Pi GPIO Pin 10 (MOSI)
  • Connect Pin 6 to Raspberry Pi GPIO pin 9 (MISO)
  • Connect Pin 7 to Raspberry Pi GPIO Pin 11 (SCLK)
  • Connect Pin 8 to Raspberry Pi 3.3V out

2. Solder wires to the MEMS Microphone breakout board. Connect to MCP3002 and Raspberry Pi.

  • ​Connect Vcc to Raspberry Pi 3.3V.
  • Connect GND to Raspberry Pi GND
  • Connect AUD to MCP3002 Pin 2

3. Plug in all the cables for the Raspberry Pi and turn everything on.

 

Build it! Software

Our goal with the Bark Back is twofold: trigger a playback sound when the dog barks, and send the data to a server where we can check it.

Here’s the ​open-source Python program for this project. Feel free to (and please do) adjust and modify the code

To get the program up and running, you need to fill in two things:

songList: Write in the file path and file name for each of the songs you want to play.

creds: Input your CloudMQTT information in this dictionary.

Step 1: Read in the SparkFun MEMS Microphone breakout board.

Read in the ADC value (between 0 and 1023) from the MEMS Microphone breakout board (via the MCP3002) using the SPI library and calculate the signal peak-to-peak amplitude.

Map the signal peak-to-peak amplitude to a Volume Unit. The current code maps the ADC range between 0 and 700 (based on quick experimentation) to a Volume Unit between 0 and 10. To adjust the sensitivity of the microphone, adjust the ADC input range.

For a thorough overview of the MEMS mic, ​check out this tutorial.

Step 2: Trigger audio player.

First we’ll need songs to play! You can quickly record sounds in GarageBand (or on your smartphone) and send ’em to the Raspberry Pi. In Python, use the subprocess library to call the omxplayer.

In the code, input the file path of the songs you want to play back in the *songList* variable (line 26). The current volume threshold is set to 7 in the main function.

Step 3: Send data to CloudMQTT Server

Use the ​Paho Client Python library to communicate with the CloudMQTT servers. To broadly summarize: Set up a Client server; define communication protocols; connect with our credentials (aka creds); and subscribe and publish our data. Most of this is done in the main function (lines 129 – 149, and lines 169 – 174).

To check on received data, go to the “Websocket UI” tab in the CloudMQTT console.

 

Test & Install & Enjoy!

Run the BarkBack.py program in Terminal or in the Python IDE (you can also use SSH to run the program after you’ve already left).

Check that you are getting volume levels in your Websocket UI tab.

Test the system by triggering the mic (clap, yell, bark, etc.) to be sure that the speakers play through all of the sounds.

Once everything is up and running, it’s recommended to solder the components to a PCB (Printed Circuit Board) if you intend to install the system for more than just a few days.

 

Project Extensions

1. Add in an RPi camera module to include video.
2. We’re already connected to the IoT, so why not throw in some more sensors! For example, you could monitor hazardous gases (perhaps methane?).
4. Prefer a reward over barking back? Create an automatic treat dispenser to reward your pet for being quiet for a few hours. Here’s a candy-dispensing tutorial for inspiration and to help get you started.
5. Share your findings and adaptations in the comments below!

Happy building!

IoT Industrial Scale!

finalscale2-v2

 

What does a baby elephant weigh?* How much impact force does a jump have?? How can you tell if a rain barrel is full without looking inside??? Answer all these questions and more by building your very own Internet of Things (“IoT”) industrial scale using the SparkFun OpenScale board!

This project is intended for folks with a lil’ bit of background using Arduino or other microcontrollers. But, whether this is your first or 137th project, check out the links in the Suggested Reading section below (and throughout the tutorial) or leave a comment if you have any questions!

Read time: ~ 15 min.

Build time: Approx. 2 – 3 hours

*To weigh a baby elephant, you might need to be a zookeeper or otherwise have an elephant friend.. but you could always weigh Fido and/or kitty!

For all you visual learners, check out a video of the project below:

 

Materials!


To follow along and build your own scale, all the parts used are listed below.

Electronics

To make the system wireless:

All these parts can be found in the wish list here.

Scale and Casing

  • Terminal blocks (5)
  • Three (3) M3 screws per load cell (total of 12)
  • One (1) project case (to protect the electronics)
  • One (1) base board, and one (1) top board (for the scale platform)
    • My base board was ~ 16″ x 16″ and my top board was ~ 12″ x 14″.
    • Both boards should be sturdy and not flex or dent.
  • Wood slats to frame the sides of the top board to hold it in place.
  • Four (4) feet for base

 

But wait! There’s some background reading..


First of all, how do we measure weight??
Strain gauges!

Also called load sensors, strain gauges measure electrical resistance changes in response (and proportional) to, well, strain! Strain is how much an object deforms under an applied force, or pressure (force per area). Check out this super awesome tutorial for more info on how strain gauges work.

Usually what you’ll find in a bathroom scale is a load cell, which combines four strain gauges in a wheatstone bridge. This project uses four disc compression load cells rated at 200 kg.

Here’s some additional background material to learn more about the components and tools used in this project:

  1. Serial Terminal Basics
  2. OpenScale Applications and Hookup Guide
  3. Getting Started with Load Cells
  4. Photon Development Guide

As usual, don’t forget to read the Datasheet for the Load Cells and any other components you with to use in your project.

Build the Electronics! Pt. 1


industrialscale-schematicv2

Connect the Load Cells!

Load cells have four signal wires:

  • Red: Excitation+ (E+) or VCC
  • Black: Excitation- (E-) or ground
  • White: Output+ (O+), Signal+ (S+)+ or Amplifier+ (A+)
  • Green (or blue): Output- (O-), Signal- (S-), or Amplifier (A-)

They also have bare (or yellow) grounding wires to block outside (electromagnetic) noise.

Connect all five load cell wires in parallel to the OpenScale terminal blocks with the corresponding labels. You might need to switch the green and white load cell wires – check this by adding weight to the load cells. If the weight is decreasing, switch the wire orientation.

The OpenScale terminal blocks are a bit cramped with four load cells, so I used the terminal blocks pictured above. If you have a case for the electronics, remember to put the connectors INSIDE the case before connecting them to the load cells (not speaking from experience or anything..).

 

Build the Electronics! Pt. 2


Connect the OpenScale to a data logger!

In addition to printing, reading, and gathering data from the Arduino serial monitor (see “Reading Load Cells!”), we can add a Photon microcontroller to connect to WiFi and upload the measurements to the Internet!

Connect the OpenScale “Serial Out” ground (“GND”) port to the Photon GND, and the OpenScale “TX” port to the Photon “RX” port. If your data logger needs power, connect the OpenScale 5V port to the data logger Vin port. That’s it!

 

Build the Base & Case!


1. Plan out, measure, and mark location of load cells.

Load cells should be at least 1″ in from the top platform board sides and installed equidistant and on the same plane (aka same height) with each other.

Each load cell needs three M3 type screws, which requires fairly precise measurements. I opted for a quick & easy solution: make a plastic stencil that marks the load cell outline and the location of the screw holes. The plastic I used was cut from a discarded strawberry container (yay, free and upcycled!).

2. Drill holes for load cell screws and attach load cells to base board.

3. Attach feet to base.

4. Secure the scale platform.

Place platform on top of the load cells. Attach wood slats to sides of base with wood glue and/or screws to secure the platform in place laterally, but not vertically. AKA, be sure that there is no resistance to the board pushing downward.

Add brackets on opposite sides for a more secure hold.

5. Place electronics into project box container (or tupperware) and drill holes for cables.

6. Admire your handiwork!

 

Connect the OpenScale!


One of the awesome features of the OpenScale program is that it outputs data to the Arduino IDE serial monitor (9600bps). All we need to do is plug in our OpenScale via USB, select the appropriate board (Arduino Uno) and port, and you can read the load cell data directly from the Arduino Serial Monitor. More info on how to do this here.

Enter ‘x’ to bring up the OpenScale settings menu. Entering ‘x’ again leaves the menu and the OpenScale will start printing data!

arduinoserialmonitor-fullmenu2_labeled

We also need to remove the serial trigger from the OpenScale. Do this by going to the menu, inputting ’t’, and turning the serial trigger to OFF.

You can change various other settings on the OpenScale using the serial monitor, including units (lbs/kg), print rate, decimal places, etc. You can adjust, or peruse, the entire OpenScale program by downloading it from GitHub!

Note: If you are connected to another microcontroller, the OpenScale does not send data when in the menu mode.

 

Tare & Calibrate the OpenScale


Tare!

We’ll need to tare the OpenScale each time it is powered up. To tare the scale, remove all weights from the scale and open the OpenScale settings menu. Input ‘1’ in the OpenScale menu, wait for it to finish taring, then exit the menu and check that the output is close to zero (+/- 5 lbs). If the reading is still off, taring again should fix the problem – if not, check that the load cell grounding wires are properly connected to ground.

Calibrate!

We also need to calibrate the OpenScale to get accurate measurements. It’s also recommended to re-calibrate the system every few weeks (or days) to avoid creep (slow change in reading over time).

To calibrate the scale:

  1. Remove all weights (except the platform).
  2. Open the OpenScale menu and select ‘2’ to open the calibration setting.
  3. Place a (known) weight on the scale and adjust the calibration factor using ‘+’ and ‘-’ until the scale reads out the calibration weight within a reasonable margin in error.*

Also, the load cell output varies with temperature (‘cause heat causes expansion), so we need to keep the system at a constant temperature (or use different calibration factors at different temperatures.

*My experimental uncertainty was about +/- 5 lbs.

 

Program the Photon!


Write a program for the Photon that will read in the serial output data from the OpenScale and push it to the IoT platform of your choice. Or you can use/modify my code 🙂

Here’s the GitHub repository for the IoT scale.

This program reads data from the OpenScale and pushes it to ThingSpeak (also prints it to the Photon serial monitor). ThingSpeak is super easy (and free!) to set up, the only downside is that it only allows data to be posted every 15s.

What you need to do to make the program work for your setup:

programcode-whattochange_labeled

  1. Include your WiFi SSID (network name) and your WiFi password in lines 53 & 54, and lines 69 & 70.
  2. Set up a ThingSpeak channel!  thingspeak-channelsetup
    1. Name the channel and write a brief description.
    2. Include at least one field name. If you want to push more data, like temperature or a timestamp, include those corresponding fields.
    3. Save the channel!
  3. Copy the “Channel ID” number and the “Write API Key” and input them into lines 84 & 85.thingspeak-apikeys_labeled

Read through the comments in the program code for more information on how the program works.

 

Test & Refine!


Prototype complete! Have your favorite human or animal stand (or awkwardly lay..) on the scale to check that it works as expected.

Check thoroughly to see if there is anything that needs to be fixed, secured, and/or improved. During my build process I noticed that a lot of the wood I was using to test would get dented by the load cells, resulting in inaccurate readings.

 

Lessons Learned & Next Steps!


My initial goal for this IoT scale was to gather data on the forces due to jumping (specifically in parkour). Alas, the OpenScale is intended for constant loads and the fastest print rate is 505 ms, which is too slow to get accurate readings on impact force.

Fortunately, we can still use the scale to gather general data and use this design as a foundation for future versions. Some quick and well-timed preliminary testing by a professional jumper (~165 lbs) resulted in the readings plotted below:

data-jumptest3

It shows a single jump, where the landing corresponds to the highest reading (~ 230 lbs), and the point just before that (~ 135 lbs) is when his feet were in the air. (The weight decrease + little blip after the the peak is when he was stepping off the scale.)

In addition to an updated program to print data faster, I’ll need waaay more data and a consistent, controlled procedure to determine any kind of reasonable relationship between impact force, jump height, and weight. Also, the top platform was a bit dented after these tests, so I’ll need a sturdier wood, or metal, scale platform.

Overall, this was a cool proof-of-concept and an informative preliminary test! Plus, there are tons of other practical uses for this simple Internet-connected scale!

 

Education Extension & Beyond!


Beyond being a great hands-on project for computer science, engineering, and electronics courses, this is a handy experimentation tool for physics classrooms! Use it to illustrate the difference between weight and mass, demonstrate how acceleration relates to force, or use the on-board temperature sensor to estimate the mathematical relationship between thermal expansion and load cell output.

Other Applications:

  • Use the system to measure the weight of a rain barrel and notify you when it is full.
  • Make a bathroom scale that keeps track of your weight (or your animal’s weight).
  • Monitor the weight of your Halloween candy to be sure that no one is sneaking some from under your nose.

Happy Building!

Interactive Survey Game!

A survey questionnaire come to life! Use (nearly) any object to gather helpful data through an interactive, engaging, and fun multiple-choice survey.

This project uses the Makey Makey microcontroller in combination with a Raspberry Pi computer to read in participants’ survey choices and save the results in a text file.

Planning & Design!

This general design is easily customized to fit a different theme. The only crucial design requirement is to use materials that conduct electricity for the survey pieces, or wrap non-conductive materials in aluminum foil.

Suggestions:
Prototype, prototype, prototype! Build different versions and test them on family, friends, co-workers, or (ideally) your target audience. Observe how folks interact with your survey, then use that to make it better! And always remember to keep it simple 🙂

Materials

Makey Makey Kit
– Computer: Raspberry Pi

– One (1) ground piece, five (5) survey response pieces, one (1) submit piece, and two (2) yes/no pieces*

22 Gauge (stranded) Wire — five (5) 10 – 16″ strips and three (3) 6″ pieces (ends stripped)

– Container:

— Wood Box (12.5″ x 12.5″)
— Plexliglass.(“12 x 12”)
— Three (3) 2″ x 2″ wood panels

* Specific materials used in this design are detailed with the corresponding procedure, although customization is encouraged!

Tools

Safety goggles, woo!
Multimeter
— Optional: Soldering iron, solder& desoldering wick
— Ruler (or calipers)
Drill w/ both drill and driver bits
Flat wood file (to prevent splinters!)
Hot glue gun
— Epoxy (permanent)
– Pliers

Reprogram the Makey Makey

To reprogram the Makey Makey, you’ll need to have the Arduino IDE with Makey Makey drivers installed. Here’s a thorough tutorial on how to do this.


1. Plug Makey Makey into computer and open the Arduino IDE.

2. Open (or copy) Makey Makey source code:
Here’s the GitHub page for the Makey Makey.
Here’s a direct link to download the full program. This is a .zip file, so be sure to extract all the files.

3. Reprogram the “click” key into an “enter” key.
For a thorough overview of how to do this, check out this tutorial.

4. Change the following keys:
These two keys are mapped in the survey program, but can be left as-is or you can choose to switch other keys (e.g. the arrow keys). Just be sure to change the mapping in the program.

A. Change the “g” into an “n”.
B. Change “space” key into “y”.

Build the Survey Response Pieces!

Specific materials used in this design:

– Two (2) wood blocks, two (2) golf balls, and one (1) jar lid.
– Aluminum foil
Unistrut 1/2″ Channel Nut with Spring
– Ten (10) 1/2″ washers
– Plexiglass [or wood] (12″ x 12″)

Procedure:

1. Wrap each of the survey response pieces at least 2 – 3 times with foil, hot gluing each layer.

2. For unistrut spring pieces, hot glue (or epoxy) the top of the spring to the bottom of each survey response piece — be sure that the metal of the spring is touching the foil of the survey piece.

3. Attach the survey pieces to plexiglass.

Determine location of survey response pieces and mark with tape. Drill a hole at each point.

Place a washer on either side of the hold and screw bolt into unistrut spring about 3 turns.

4. Connect a wire to each of the unistrut spring pieces.

Wrap wire around base of bolt (between washer and plexiglass). Hand tighten the bolt to secure wire without squishing it

Build the Ground Piece!

Specific materials used in this design:
– Styrofoam ball
– Metal pipe
– Flange stand for pipe
– Aluminum foil
– Twelve (12) washers
– 4 wood screws
– Wood panel (2″ x 2″)

Procedure

1. Build a stand for the styrofoam ball — use conductive materials or wrap pieces in foil.

2. Wrap styrofoam ball in aluminum foil, leaving a “tail” of foil. Place ball on stand and push the foil tail against the inside of  Hot glue pieces together.

3. Cover the exposed end of the ground wire (24″) to the inside, or bottom, of base and adhere with tape or epoxy.

5. Add a layer of two (2) washers under base to avoid squishing the wire, then connect base to wood pane via screws or epoxy.

Build the Enter Key!

Specific materials used in this design:

– Clothespin
– Wood panel (2″ x 2″)
– One (1) wood screw + one (1) washer

The screw should be about 1/4″ longer than the wood thickness.

– Aluminum foil

Procedure:

1. Wrap one of the handles of the clothespin in foil.

2. Remove clothespin spring clamp, align other side of the clothespin on wood panel, and drill in a screw and washer.

Foil on the other side of the clothespin should make contact with the washer + screw when closed.

3. Reconnect spring clamp and other side (may need pliers). Epoxy bottom of clothespin to wood panel.

4. Use alligator clip or wrap wire around screw and secure with hot glue.

Make the Yes and No Keys! 

Specific materials used in this design:
– Two (2) plastic container lids
– Two (2) wood panels (2″ x 2″)
– Two (2) wood screws and washers

Each screw should be about 1/4″ longer than the wood thickness.

– Aluminum foil


Procedure

1. Cut circle out of container lids. Wrap in foil.

2. Align lids on wood panels and drill in a wood screw with washer on top — be sure the screw slightly pokes through the back of the wood panel.

3. Use alligator clip or wrap wire around screw and secure with hot glue. 

Connect Pieces to Makey Makey

1. Connect ground piece lead to Makey Makey ground pads.

2. Connect survey game pieces to the first five (5) Makey Makey back header pins on the left: “w”, “a”, “s”, “f”, and “d”.

3. Connect the no button to the last (6th) back header pin, “g”

4. Connect the yes button to the “space” pads.

5. Connect the submit piece to the “click” pads.



Load the Survey Program!

Using a Raspberry Pi computer means that all of the electronics can fit into the game box! Write up a program in Python to cycle through a series of survey questions and five possible choices that map to the survey response pieces.

Here’s my code:
GitHub page!
Python program only.

Final Touches & Case!

This case is designed to withstand high traffic, experimentation, and children — and to be easily (and cheaply) fixable and adjustable. Use this design or customize your own!

Materials:
12.5″ x 12.5″ wood box
1″ x 10 ” wood panel

Procedure:
1. Epoxy wood panel onto front of box.

2. Drill the submit, yes, and no keys into the wood panel.


Recommended to put the “submit” button on the far right (switched this after further testing and feedback).

 

3. Drill hole large enough to fit an HDMI port in the back panel of the box.

I used two 3/8″ bits and filed down the hole until the HDMI port fit.

4. Label the survey game pieces and the submit, yes, and no keys.

Test, & Install!

Connect the Raspberry Pi to a monitor, keyboard, and the Makey Makey. Test the program and double check all the keys. Once everything is up and running, remove the keyboard (and mouse if connected).

Load the python program, stand back, and let passersby have a blast participating in a survey!

Hazardous Gas Monitor

Build a portable gas monitor to check for dangerous levels of hazardous gases in your home, community, or on the go and prevent your friends from lighting a cigarette during  a gasoline fight.*

This tutorial shows you how to build a web-connected “canary” monitor for three hazardous gases: Liquid Propane Gas (“LPG”), Methane (aka natural gas), and Carbon Monoxide (“CO”) . Using the Particle Photon microcontroller, the sensor readings are converted into parts-per-million (“PPM”) and uploaded to the data.sparkfun.com web service.

*Please note that this is solely a movie reference — gasoline fights should probably be avoided in real life.


Helpful Background Info!


1. How to set up the Particle Photon.

2. Pushing data to the data.sparkfun.com web server.

3. New to relays? Check out this a handy reference.

4. Here’s a helpful overview on the N-Channel MOSFET.

5. For powering the Photon, here’s a thorough guide on the Photon Battery Shield.

6. Highly recommended to peruse the datasheets for the three gas sensors.


Choosing a Battery!


The gas sensors used in this project require a fair amount of current, about 0.17 A each at 5V. To make the system portable, we’ll need a high capacity battery. One easy, and affordable, option is to use four (rechargeable) AA batteries in series. These batteries will last about 4 hours.

Another option is to use a lithium ion battery (“LIB”). LIBs have a higher capacity than AAs, but typically run at a lower voltage. If you go with this option, you may need to include a correction factor when you calculate the sensor value or boost the battery voltage with a transistor or other component.

The photo above shows a table with the approximate lifetime of a few different battery options.

If all of this sounds confusing, here’s a more thorough tutorial.


Materials!


Here’s a Wish List that includes all the necessary components for this project!

Microcontroller and Accessory Components

Particle Photon microcontroller

SparkFun Photon Battery Shield

– One 2000 mAh Polymer Lithium Ion Battery

Surface Mount DC Barrel Jack

Barrel jack to USB power supply cable

One (1) Lamp Switch

– Optional: Male-to-Female JST connector cable

Gas Sensor Circuit

One (1) Project Case

– One (1) 4 AA battery case

– Four (4) AA Rechargeable Batteries

One (1) Toggle Switch (SPST switch)

Piezo Buzzer

Three (3) Red LEDs

– Three (3) 10 kΩ resistors

One (1) PCB

22 Gauge stranded wire

– Optional: Electrical connectors (3-5)

LPG (MQ6) Gas Sensor

MQ6 LPG Gas Sensor

Gas Sensor Breakout Board

– One (1) 4.7 kΩ resistor

– One (1) 5V Voltage Regulator

Methane (MQ4) Gas Sensor

MQ4 Methane Gas Sensor

Gas Sensor Breakout Board

– One (1) 4.7 kΩ resistor

– One (1) 5V Voltage Regulator

Carbon Monoxide (MQ7) Gas Sensor

MQ7 CO Gas Sensor

Gas Sensor Breakout Board

– One (1) 4.7 kΩ resistor

– One (1) 5V Voltage Regulator

– One (1) 5V SPDT Relay

– One (1) N-Channel MOSFET

– One (1) 10 kΩ potentiometer

– One (1) 10 kΩ resistor


Tools!


– Soldering Iron

– Wire cutters/strippers

– Drill

– Screwdriver

– Epoxy (or hot glue)


Build it! Electronics


1. Solder gas sensor breakout boards to gas sensors. Orientation doesn’t matter, just be sure that the silkscreen (aka labels) are facing down so that you can read them (had to learn that one the hard way..). Solder wires to the gas sensor breakout board.

2. Solder three voltage regulators to the PCB board. For each regulator, connect positive battery output to the regulator input, and connect middle voltage regulator pin to ground.

3. Connect the LPG (MQ6) and Methane (MQ4) sensors.

For each sensor:

  1. Connect H1 and A1 to the output of one of the voltage regulators (recommended to use an electrical connector).
  2. Connect GND to ground.
  3. Connect B1 to Photon analog pin (LPG goes to A0, Methane to A1)
  4. Connect a 4.7 kΩ resistor from B1 to ground.

4. Connect the CO (MQ7) gas sensor.

*Aside: The MQ7 sensor requires cycling the heater voltage (H1) between 1.5V (for 90s) and 5V (for 60s). One way to do this is to use a relay triggered by the Photon (with the aid of a MOSFET and potentiometer) — when the relay is not powered, the voltage across H1 is 5V, and when the relay is powered the voltage across H1 is ~ 1.5V.

  1. Connect GND to ground.
  2. Connect B1 to Photon analog pin (A2). Connect 4.7 kΩ resistor from B1 to ground.
  3. Connect A1 to third voltage regulator output (5V source).
  4. Connect Photon 3.3V pin to positive relay input.
  5. Connect Photon Digital Pin D7 to left MOSFET pin, and a 10 kΩ resistor to ground.
  6. Connect middle MOSFET pin to relay ground pin. Connect right MOSFET pin to ground.
  7. Connect relay Normally Open (“NO”) pin to H1, and the Normally Closed (“NC”) pin to middle potentiometer pin.
  8. Connect right potentiometer pin to ground, and left pin to H1.
  9. Adjust potentiometer resistance until it changes the relay output to ~ 1.5V when the relay receives power.

5. Connect an LED and 10 kΩ resistor to each of the Photon digital pins D0, D1, and D2. Connect buzzer to Photon digital pin D4.


6. Connect toggle switch between battery pack and PCB board power. Recommended to include an electrical connector for the battery pack to make it easier to switch out batteries.


7. Connect lamp switch between LIB and Photon battery shield — recommended to use an extra JST cable for this to keep the LIB battery cable in tact (and make it easier to install the lamp switch).

8. Label wires!


Build a Case!


1. Drill hole for toggle switch on case lid.

2. Drill 3 holes in the case lid for the LED lights to shine through, and 3 holes for the gas sensors to have air contact. Adhere components on the inside of the lid.

3. Drill hole in the side of the case for barrel jack USB cord to connect to the Photon Battery Shield.

4. Drill two small holes on the side of the case for the lamp switch cable. Adhere lamp switch to side of case.

5. Label the LEDs with its corresponding gas sensor on the outside of the case.

6. Check electrical connections and, if everything is good to go, coat electrical connections in epoxy or hot glue.


Calculate Gas Sensor PPM!


Each of the gas sensors outputs an analog value from 0 to 4095. To convert this value into voltage, use the following equation:

Sensor Voltage = AnalogReading * 3.3V / 4095

Once you have the sensor voltage, you can convert that into a parts per million (“PPM”) reading using the sensitivity calibration curve on page 5 of the gas sensor datasheets. To do this, recreate the sensitivity curve by picking data points from the graph or using a graphical analysis software like Engauge Digitizer .

Plot PPM on the y-axis and V_RL on the x-axis, where V_RL is the sensor voltage. There is a lot of room for error with this method, but it will give us enough accuracy to identify dangerous levels of hazardous gases. Estimated error bars are around 20 PPM for the LPG and Methane sensors, and about 5 PPM for the CO sensor.

Next, find an approximate equation for the PPM vs. V_RL curve. I used an exponential fit (e.g. y = e^x) and got the following equations:

LPG sensor: PPM = 26.572*e^(1.2894*V_RL)

Methane sensor: PPM = 10.938*e(1.7742*V_RL)

CO sensor: PPM = 3.027*e^(1.0698*V_RL)


Program it!


First, set up a data stream on the [data.sparkfun.com service](http://data.sparkfun.com). Next, write a program to read in the analog value of each gas sensor, convert it to PPM, and check it against known safe thresholds. Based on OSHA safety standards, the thresholds for the three gases are as follows:

  • LPG: 1,000 PPM
  • Methane: 1,000 PPM
  • CO: 50 PPM

If you want to get up and running quickly, or are new to programming, feel free to use my code! Use it as-is or modify to suit your particular needs.

Here’s the GitHub page!

Here’s the raw program code.

Change the following in the code:

1. Copy and paste your data stream public key to the array called `publicKey[]`.

`const char publicKey[] = “INSERT_PUBLIC_KEY_HERE”;`

2.Copy and paste your data stream private key to the array called `privateKey[]`.

const char privateKey[] = “INSERT_PRIVATE_KEY_HERE”;

To monitor the Photon output, use the Particle driver downloaded as described in the [“Connecting Your Device” Photon tutorial](https://docs.particle.io/guide/getting-started/connect/photon/). Once this is installed, in the command prompt, type `particle serial monitor`. This is super helpful for debugging and checking that the Photon is posting data to the web.


Be a Citizen Scientist!


Now we get to test and employ our gas monitor! Turn the batteries for the gas sensors on using the toggle switch, wait about 3 – 5 minutes, then turn the Photon on with the lamp switch (the gas sensor heater coils take some time to heat up). Check that the Photon is connected to WiFi (on-board LED will slowly pulse light blue) and is uploading data to the server. Also check that the gas sensor readings increase when in proximity to hazardous gases — one easy, and safe, way is to hold a lighter and/or a match close to the sensors.

Once up and running, use the sensor to monitor for dangerous gas leaks around your home, school, workplace, neighborhood, etc. You can install the sensor in one location permanently, or use it to check gas levels in different locations (e.g. SoCal..).

Educator Extension!

This project is a perfect excuse for a hands-on chemistry lesson! Use the monitor to learn the fundamentals of various gases — what kinds of gases are in our environment, how are different gases produced, and what makes some of them hazardous or dangerous.

Study the local environment and use a lil’ math to record and plot LPG, Methane, and CO in specific locations over time to see how the levels change. Use the data to help determine what causes changes in the gas levels and where/when gas concentrations are the highest.

 


More to Explore!


Monitor hazardous gas concentrations around your neighborhood or city and use the results to identify problem areas and improve public safety.

Use Bluetooth, or your smartphone WiFi, to connect to the Photon and upload data to the web wherever you are!

Include other sensors, gaseous or otherwise , to create a more comprehensive environmental monitoring system.

Sound Reactive EL Wire Costume

Bring science fiction to life with a personalized light-up outfit! EL wire is a delightfully futuristic-looking luminescent wire that has the added benefit of staying cool, making it ideal for wearable projects. Combining sensors and a microcontroller with EL wire allow for a wide range of feedback and control options.

This project uses the SparkFun sound detector and the EL Sequencer to flash the EL wire to the rhythm of ambient sound, including music, clapping, and talking.

Materials

Electronics

 

El Wire comes in a variety of colors, so pick your favorite(s)!

Costume

  • Article(s) of clothing

For a Tron-esque look, go for stretchy black material. Yoga pants and other athletic gear work great!

  • Belt
  • Old jacket with large pocket, preferably zippered or otherwise sealable.

The pocket will house the electronics. If you intend to wear the costume outdoors in potentially wet weather, choose a pocket that is waterproof (i.e. cut a pocket from a waterproof jacket).

  • Piece of packing foam or styrofoam (to insulate the sound detector).

Tools

Build it! Pt. 1

CAUTION: Although it is low current, EL wire runs on high voltage AC (100 VAC). There are exposed connections on the EL Sequencer board so BE CAREFUL when handling the board. Always double (and triple) check that the power switch is OFF before touching any part of the board. For final projects, it is recommended to coat all exposed connections in epoxy, hot glue, electrical tape, or other insulating material.

1. Test EL Sequencer with EL Wire.
Connect the inverter, battery, and at least one strand of EL wire to the EL Sequencer. (Note that the two black wires of the inverter correspond to the AC side.)
Be sure that the EL Wire lights up and blinks when you power the EL Sequencer on battery mode.

2. Solder header pins onto 5V FTDI pinholes on the EL Sequencer and onto the VCC, ground, and A2 input pins.

3. Solder header pins to the sound detector.

4. Connect sound detector to EL Sequencer via female-to-female breadboard wires (or solder wire onto header pins).
Connect the sound detector VCC and ground pins to the VCC and ground pins on the EL Sequencer. Connect the sound detector gate output to the A2 input pin on the EL Sequencer. If you are using the envelope and/or audio output signals, connect these to pins A3 and A4 on the EL Sequencer (more on this in the Program It! section).

Build it! Pt. 2

1. Make a protective casing for the sound detector using packing foam or styrofoam to prevent jostling or other physical vibrations (aka collisions) from triggering it.

Place sound detector on top of foam, outline the board with a pen, and cut out a hole in the foam for the detector to fit snugly inside. Also recommended to epoxy the wires onto the foam (but not the sound detector board).

2. Cut out a pocket from the jacket and sew onto the belt.

3. Put belt on, connect EL Wire to EL Sequencer, and place EL Sequencer in pocket pouch. Determine approximate placement of each EL wire strand based on location of electronics.

Build it! Pt. 3

1. Mark and/or adhere the base of the EL wire JST connector onto clothing, allowing the full length of the connector to flex. Be sure that the JST connector can easily reach the EL Sequencer.

2. Starting at the basse of the JST connector, attach EL wire strands to your chosen article of clothing.

Sew EL wire onto clothing using strong thread or dental floss, or use an appropriate fabric adhesive.
Prior to adhering the EL wire, it is recommended to use safety pins to determine placement of the EL wire on each article of clothing while you are wearing it. EL wire is flexible but not so stretchy, so give yourself some wiggle room.

It is also recommended to use separate EL wire strands on different articles of clothing to facilitate the process of taking it on/off.

Program it!  

1. Connect EL Sequencer to computer via 5V FTDI BOB or cable. 

2. Program the EL Sequencer using the Arduino platform; the EL Sequencer runs an ATmega 328p at 8 MHz and 3.3V.

3. Determine how you want to use the sound detector output(s) to control the EL wire. The sample program below utilizes the gate channel output to turn on the EL wire if there is a sound detected.

Sample Program:

// Sound Activated EL Wire Costume<br>// Blink EL Wire to music and other ambient sound.
//JenFoxBot
void setup() {
  Serial.begin(9600);  
  // The EL channels are on pins 2 through 9
  // Initialize the pins as outputs
  pinMode(2, OUTPUT);  // channel A  
  pinMode(3, OUTPUT);  // channel B   
  pinMode(4, OUTPUT);  // channel C
  pinMode(5, OUTPUT);  // channel D    
  pinMode(6, OUTPUT);  // channel E
  pinMode(7, OUTPUT);  // channel F
  pinMode(8, OUTPUT);  // channel G
  pinMode(9, OUTPUT);  // channel H
//Initialize input pins on EL Sequencer
  pinMode(A2, INPUT);
}
void loop() 
{
  int amp = digitalRead(A2);
    
  //If Gate output detects sound, turn EL Wire on
  if(amp == HIGH){
    
    digitalWrite(2, HIGH); //turn EL channel on
    digitalWrite(3, HIGH);
    digitalWrite(4, HIGH);
    delay(100);
  }
  
    digitalWrite(2, LOW); //turn EL channel off
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
  
}

This program is just one example of what is possible with the SparkFun sound detector. Depending on your needs, different responses can be achieved by using the “envelope” and “audio” outputs of the sound detector. The EL Sequencer can individually control up to 8 different EL wire strands using the three sound detector output signals, so there are tons of possiblities to customize your sound-activated outfit!

More information about the sound detector output signals:
The gate channel output is a digital signal that is high when a sound is detected and low when it is quiet. The envelope channel output traces the amplitude of the sound, and the audio output is the voltage directly from the microphone.

In the photo provided, the red trace corresponds to the gate signal output, the light green trace corresponds to the envelope signal output, and the dark green trace corresponds to the audio signal output.

Test, Secure, & Show Off!

Connect all components to the EL Sequencer (inverter, battery, sound detector) and place in belt pouch. Turn the system on, make some noise (e.g. clapping, snapping, or music) and check that the EL wire flashes when there is a sound.

If the outfit works as expected, secure all connections by coating them in a (thin) layer of epoxy. Let dry for at least 24 hours. Epoxy is a very permanent adhesive, so if you want to reuse any of the components, try other adhesives like hot glue or electrical tape (less secure, but adjustable and removable).

You can reduce the overall strain on individual connections by ensuring that wires are securely fastened to the belt and/or pouch approximately one inch (1″) from all connections. The goal is to allow the EL wire to flex while keeping electrical connections rigid, as the connections are the most likely point of breakage.

Wear your one-of-a-kind, high-tech outfit and go show it off to the world!

EL Wire Light Up Dog Harness

Whether it’s to keep Fido (or in my case, Marley) visible on an adventure or as an awesome all-year-round costume, a light up dog harness is an excellent accessory for your favorite pup.

EL wire is a great option for wearable lights. It stays cool, is flexible, and comes in lots of different colors. This design uses the SparkFun EL Sequencer to automatically turn on EL wire when it is sufficiently dark outside so you don’t have to worry
about locating Mr. Dog to turn the system on.

Here’s a video tutorial for this project.

Recommended Reading

If you are new to electronics, EL wire, or the EL Sequencer, or would like more information on the main components in this project, check out this tutorial.As this design also uses a lithium ion battery, I also recommend reading this tutorial to give you an overview on proper care and handling of lithium batteries.

Materials

Electronics

  • EL Wire
    • EL wire comes in variety of colors, pick your favorite!

Harness Materials

  • Dog harness
    • A vest or backpack will also work.
  • Waterproof jacket with pocket(s)
  • Optional: Tupperware or other sealable plastic container

Tools

  • Safety goggles
  • Soldering Iron
  • Wire Cutter/Stripper
  • Epoxy (waterproof)
  • Scissors
  • Needle + thread OR fabric adhesive
  • Optional: Velcro

Build it! Pt. 1

**CAUTION:** Although it is low current, EL wire runs on high voltage AC (100 VAC). There are exposed connections on the EL Sequencer board so BE CAREFUL when handling the board. Always double (and triple) check that the power switch is OFF before touching any part of the board. For final projects, it is recommended to coat all exposed connections in epoxy, hot glue, electrical tape, or other insulating material.

1. Test the EL Sequencer with EL wire.
Connect EL Wire, inverter, and battery to EL sequencer.
Turn on power switch and check that the EL wire turns on (should be blinking). You can connect, and control, up to 8 different strands of EL wire.

2. Solder header pins onto 5V FTDI pinholes on the EL Sequencer.

 
3. Solder header pins to the “GND,” “VCC,” and “A2” pinholes EL Sequencer (right side).

4. Solder male end of breadboard wires to ambient light sensor. Coat exposed metal on the sensor in epoxy (do not coat actual sensor).

Note: Recommended to solder the pins on the bottom of the sensor so that the sensor can more easily be attached to the harness (found this out the hard way..).

 

 

 

 

Build it! Pt. 2 

1. Attach EL Wire to harness.
Sew EL wire onto harness with dental floss for a strong, durable bond. Can also use an appropriate fabric adhesive.For straps/buckles: leave about 1″ of unattached EL wire on either side of the strap/buckle.You can either wrap the ELwire for its entire length, or cut it and insulate the ends.2. Make a durable pouch for the electronics.
For a waterproof pouch, cut out a pocket in a waterproof jacket. I also included a small tupperware container to house the electronics in the pouch to further insulate and protect them from weather and dog conditions.

Build it! Pt. 3

1. Attach electronics pouch to harness.
Sew pouch onto top side of harness, or wherever is comfortable and practical for your pup. Recommended to put harness on dog to find a suitable location for the pouch.

2. Cut small holes on underside of pouch for the EL wire JST connector and the light sensor wires.

3. Attach and secure light sensor to harness. Recommended to put harness on your dog and mark location for light sensor so that it faces upward.
There was an ideal flap in the rainjacket pocket for me to cut a hole, push the sensor through, and epoxy the other side. You can also use velcro or sew the light sensor onto the pocket or harness, just be sure that it stays stationary and won’t get covered when the dog is moving.

4. If using tupperware, cut or drill holes in tupperware for EL wire JST connector and light sensor wires.
If you are not using tuperware, it is recommended to cushion the electronics and/or epoxy all connections (except the JST connectors) to protect them from your dog’s antics.

5. Connect EL wire and light sensor to EL Sequencer (through holes in the tuperware), then epoxy the holes to keep wires in place and maintain a waterproof seal.

Program It!

1. Connect EL Sequencer to computer via 5V FTDI BOB or cable. 

2. Program the EL Sequencer using the Arduino platform; the EL Sequencer runs an ATmega 328p at 8 MHz and 3.3V. 


3. Write a program to read in the analog value of the ambient light sensor, turn on the appropriate EL wire channels at a value that corresponds to low light, and turn off once the light sensor value is above the low light threshold.Here’s a sample program with a preset light threshold:

// EL Wire Dog Harness Program
// Turn EL wire on when ambient light is low.
// JenFoxBot
// Based on test sketch by Mike Grusin, SparkFun Electronics
void setup() {
  Serial.begin(9600);  
  // The EL channels are on pins 2 through 9
  // Initialize the pins as outputs
  pinMode(2, OUTPUT);  // channel A  
  pinMode(3, OUTPUT);  // channel B   
  pinMode(4, OUTPUT);  // channel C
  pinMode(5, OUTPUT);  // channel D    
  pinMode(6, OUTPUT);  // channel E
  pinMode(7, OUTPUT);  // channel F
  pinMode(8, OUTPUT);  // channel G
  pinMode(9, OUTPUT);  // channel H
  // We also have two status LEDs, pin 10 on the EL Sequencer, 
  // and pin 13 on the Arduino itself
  pinMode(10, OUTPUT);     
  pinMode(13, OUTPUT); 
  pinMode(A2, INPUT);  
}
void loop() 
{
  int x,status;
  
  //If ambient lighting is too low, turn on EL wire
  if(analogRead(A2) < 50){
    digitalWrite(2, HIGH); //turn EL channel on
    delay(1000); //wait 1 second
    
    //Keep EL wire on until light sensor reading is greater than 50
    if(analogRead(A2) > 50){
      digitalWrite(2, LOW); //turn EL channel off
      delay(10);
    }
    
    Serial.println(analogRead(A2)); // Use this to check value of ambient light 
    
    digitalWrite(10, status);   // blink both status LEDs
    digitalWrite(13, status);
  }
}

4. Check that the EL wire turns on when the ambient light is low, and turns off in bright light. 

Test it and Put it to Work!

Place EL Sequencer, inverter, and battery inside the pouch (and tupperware). Connect all components to the EL Sequencer and turn it on using battery power. Test it in low and bright light to ensure that it functions properly.

If system works as expected, put on dog and go exploring!As an added bonus, you can use the electronics pouch to store other small, non-magnetic items. Enjoy!