Introduction: Cool Shades for Under $25 (LED Matrix Sunglasses)

I have always wanted to build my own LED Matrix sunglasses, ever since I saw someone adorning one at a hackathon, a year and a half ago. However, time and time and again, school has interfered with my plans to build one for myself. Now, I have the opportunity to build my own as well as present my experiences to you, in the hopes that you may create one for yourself as well.

I would like to emphasize all the readers that this is your project. Let your own artistic and engineering creativity lead and use this 'ible as a guide. I have written it in such a way both be a comprehensive guide and to communicate the bare essence of the build such that you may concoct your own design.

Disclaimer: I am in the midst of completing the rest of the guide with more images to come. I have rushed the publishing and submission of this 'ible to make it to the deadline of the Lights Contest. It will be finalized as of May 31th 11:59PST

Step 1: Materials and Tools

Materials:
1. (100 pieces) 3mm Green LEDs - $12

2. (1 piece) 4017 Decade Counter - $1

3. (16 pieces) 330 Ohm 1/2 Watt Resistor - $0.72

4. (2 pieces) 74HC595 - 8 bit Shift Register $2.50

5. (6 pieces) 1K Ohm 1/2 Watt Resistor - $0.27

6. (6 pieces) 2N3904 Transistor - $0.5

7. (3 Pieces) 8 pin IC socket - $1

8. Sunglasses - $ free

9. Jumper Wires - $ 3

10. Perf Board - $1

Tools:

1. Soldering Iron and Solder

2. Scissors and X-acto blade

3. Wire Strippers

4. Pliers

5. Arduino and Computer

Step 2: Testing Each of the LEDs

This step is very important as it will save a lot of time debugging the LED if matrix if even only one of the LED is broken.
1. Using a breadboard and Arduino, plug in a red jumper cable from the 5V or VCC header pin of the Arduino to the red rail of the breadboard, and plug in a black jumper cables from the GND (ground) header pin of the Arduino to the blue rail of the breadboard.

2. Connect a 330 Ohm 1/2 Watt resistor from the 5V or VCC (red) rail on the breadboard and plug in the other side on an empty slot in the middle of the breadboard.

3. Connect the LED by inserting the longer pin of the LED in the same column number of the breadboard.

4. Insert the shorter leg of the LED to the GND (blue) rail on the bread board. This will light up the LED. If the LED does not light up then, that particular LED is defective.

Note: When troubleshooting, inspect the resistor visually that it is not burnt and verify that the voltage difference between the VCC and GND is 5V using a multimeter.
To check the voltage difference using a multimeter, go to the segment of the multimeter selection with a V with a straight bar and dotted-line bar on top and select 20. Then, connect the red wire to the red jumper cable from the Arduino and the black wire to the black jumper cable from the Arduino.

Step 3: Drawing the Outline

1. On a blank piece of paper, hold the sunglasses such that it flattens out on the paper, then trace the outer outline of the sunglasses.

2. Pop out both lenses from the sunglasses and align it with the traced outer outline.

3. Trace the inner outline of the sunglasses on the piece of paper.

4. Divide the length and width of your sunglasses to the number of LEDs to be placed lengthwise and widthwise plus one. This will be the length increments for which the gridlines shall be drawn.

5. Using a ruler, measure, mark, and rule the length increments needed lengthwise and widthwise, based on the length increment calculated from the previous step. This will serve as the grid points for which the LEDs shall be aligned.

Step 4: Designing the Sunglasses

Design how many LEDs can be realistically fitted on the sunglasses horizontally and vertically.

I chose to have 16 LEDs horizontally and 5 LEDs vertically giving me an aspect ratio of about 3:1.

How it Works?

First we need to understand the idea of multiplexing. Multiplexing is the ability to send send a signal to choose where to send this signal. We can view multiple LEDs at once by flashing one LED at a time but at a very high rate of speed such that the human eye cannot observe the flashing. This is called PWM signals. Thus, forming an illusion of a certain pattern of LEDs are being lit while having full control as to which LED is being controlled.

The number of rows and columns dictates the amount of shift registers (material 4), resistors (material 3 and 5), and transistors (material 6) you will need.

Horizontally:

The number of LEDs horizontally is the exact number of 330 Ohm Resistors (material 3) you will need. The shift register has 8 input and output pins so divide your columns by 8

Vertically:

The number of LEDs vertically is the exact number of 1K Ohm Resistors (material 5) and transistors (material 6).

Step 5: Couloring the Negative Pins of the LEDs

1. Using a permanent marker, colour the negative pin of the LED. This will make it easier to identify which pin is positive or negative when they are bent.

Step 6: Bending the LED Pins

1. Bend the both pins of the LEDs 180 degrees in opposite directions from each other. Using the edge of a table as a guide, when pushing down on the LED is helpful.

Step 7: Cutting and Taping the LEDs in Place

1. Cut the negative LED pins short, approximately 2-3 mm long.
2. Align the positive pin along the vertical grid lines placing the LED at the line intersection.
2. Tape the positive pin down along the pin diagonally such that it does not rotate along the pin's axis.
4. Repeat until a full row is completed.

Step 8: Soldering the Negative Terminal Bar

1. Solder all the negative LED pins onto a strip of wire since all the negative terminal needs connect to a common voltage input.
2. Repeat this for all five rows.

Step 9: Soldering the Positive Column Terminal Bars

Similar to the previous step, each of the positive column terminals need to be soldered and connected to a common ground. However, this step is quite a bit more involved than the previous, since it must be ensured that there are no contacts or short circuits between the positive and negative pins of the LEDs.

1. First, solder each of the columns of the first and second row of LEDs.
2. Then, solder each of the columns of the fourth and fifth rows of LEDs
3. Cut the positive pin of the third row of LEDs to approximately 2-3 mm in length.
4. Measure and cut the appropriate length wire to connect each of the first and second row positive bar to the third row.
5. Strip both end of this wire using a pair of wire strippers ot scissors and pliers to prevent the wire from slipping as it is a small length of wire. Alternatively, you may find it easier, as I have, to slide off the casing completely and snip a small portion of it, the slip it back on.

6. Tin both ends of the wire and the contact points. Using a pair of pliers to hold the wire solder each of the positive pins from the first and second row to the each of the corresponding column of the third row.
7. Repeat to solder the columns of the third row to the fourth and fifth rows.

8. Solder a 330 Ohm 1/2 Watt Resistor to each of the columns on the first row of LEDs. Then, bend all the pins of the resistor 90 degrees so such the wiring of the jumper will be neater.

Step 10: Glue the LED Matrix Onto the Sunglasses.

1. Pop the lenses of the sunglasses back into the frame.

2. Using a hot glue gun, place a generous bead of hot glue the bottom wire grids of the LED Matrix wires onto the sunglasses. You may also use the hot glue as an insulator for the bare wires. Though there is no risk of electric shock since the voltage and current are both too low for the human body to register.

Step 11: Cutting the Header Pins to Length

1. Count two sets of eight female header pins and a set of five female header pins. Then, score it with an X-acto blade on all sides.

2. Slowly and carefully cut the header pins to length using scissors.

Step 12: Soldering the Shift Register Multiplexer Circuit

Use the schematic above as a guide for soldering the shift register multiplexer circuit. The steps taken, as well as the order of bus paths soldered is noted below.

1. Place the eight pin IC sockets into the perf board and tape it down to prevent it from moving when soldering
2. On the opposite side of the board, solder each pins to their respective pads.
3. Then, place the eight pin headers next to the IC sockets, respectively and tape them in place.
4. Solder each of the pins of the header pins.
5. On the copper side of the perf board, connect pin 8 and pin 13 for both of the IC Sockets using a jumper wire. This is the ground pin of the IC.
6. Similarly, connect pin 10 and pin 16 using a jumper wire. This is the voltage input or VCC of the IC.
7. Using a jumper wire, solder pins 8, 11, 12, 14 and 16 in parallel for all the IC sockets
8. Designate one of the IC socket for the shift register as the primary IC socket and the other as secondary, tertiary, etc.
9. Solder pin 9 of the primary IC socket to pin 14 of the secondary IC socket. If you have more than 2 shift registers, then continue to solder pin 9 of the secondary IC socket to pin 14 of the tertiary IC socket, and so on.
10. Solder pins 1-7 and 15 of each of the IC sockets to its respective header pins.
11. Solder a five pin header to the right of the primary IC socket.
12. Solder pins 8, 11, 12, 14, and 16 of the primary IC socket to the five pin header and label which pin number is soldered to the header.
13. Gently place each of the shift register ICs into their IC sockets, such that the notch on the ICs matches the notch on the IC sockets.


Lastly, verify all connections using the continuity test of a multimeter based on the schematic. In addition, verify that there are no short circuits between VCC and ground or any wrong connections by both visual inspection and using the continuity test of a multimeter.

Step 13: Soldering the Decade Counter Circuit.

Use the schematic above as a guide.

1. Place the IC socket on any empty space on the perf board, while ensuring there are empty pads adjacent to the pins and tape it down.

2. Place the transistors adjacent to the pin, leaving an empty space between each transistors and tape it down.

3. On the copper side of the perf board, solder each of the pins of the IC sockets and transistors to their respective pad.

4. Snip the excess leads of the transistors.

5. Solder the resistors in the order as shown in the schematic above.

6. Solder the GND pin to the GND pin of the shift register multiplexing circuitry

7. Solder the VCC pin to the VCC pin of the shift register multiplexing circuitry

8. Gently place the decade counter IC into the IC socket, such that the notch on the IC matches the notch on the IC socket.

Step 14: Wiring the Connections Using Jumper Cables.

1. Tear off two sets of eight female-to-male jumper wires from the jumper wire ribbon set. This will connect the header pin from the shift register multiplexing circuitry to the columns of the LED matrix.

2. Tear off a set of 5 male-to-male jumper wires form the jumper wire ribbon set. This will connect the 5 pin header set from the shift register to connect to the VCC, GND, pin 10, 11, and 12 on the Arduino. The latter three are the signal wires from the Arduino which signals which of the LEDs shall turn on.

3. Tear off a set of 2 male to male jumper wires form the jumper wire ribbon set and connect it to the 2 pin header set adjacent to the decade counter IC and connect it to pins 8 and 9 as following the schematic in the previous step.

4. Connect the wires as describe in all the previous steps and organize them such that they border the edges of the sunglasses.

Step 15: Compiling the Arduino Code

1. Download the Arduino IDE from Arduino.cc

2. Copy and paste the following code to the Arduino IDE and click "Compile" (first button from the left of the menu bar).

/* * Show messages on an 8x8 led matrix, * scrolling from right to left. * * Uses FrequencyTimer2 library to * constantly run an interrupt routine * at a specified frequency. This * refreshes the display without the * main loop having to do anything. * */#include #define SPACE { \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0}, \ {0, 0, 0, 0, 0, 0, 0, 0} \}#define H { \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 1, 1, 1, 1, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0} \}#define E { \ {0, 1, 1, 1, 1, 1, 1, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 1, 1, 1, 1, 1, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 1, 1, 1, 1, 1, 0} \}#define L { \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 0, 0, 0, 0, 0, 0}, \ {0, 1, 1, 1, 1, 1, 1, 0} \}#define O { \ {0, 0, 0, 1, 1, 0, 0, 0}, \ {0, 0, 1, 0, 0, 1, 0, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 1, 0, 0, 0, 0, 1, 0}, \ {0, 0, 1, 0, 0, 1, 0, 0}, \ {0, 0, 0, 1, 1, 0, 0, 0} \}byte col = 0;byte leds[8][8];// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10,9, 8, 7, 6};// col[xx] of leds = pin yy on led matrixint cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06],pins[11], pins[15], pins[16]};// row[xx] of leds = pin yy on led matrixint rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1],pins[7], pins[2], pins[5]};const int numPatterns = 6;byte patterns[numPatterns][8][8] = { H,E,L,L,O,SPACE};int pattern = 0;void setup() { // sets the pins as output for (int i = 1; i <= 16; i++) { pinMode(pins[i], OUTPUT); } // set up cols and rows for (int i = 1; i <= 8; i++) { digitalWrite(cols[i - 1], LOW); } for (int i = 1; i <= 8; i++) { digitalWrite(rows[i - 1], LOW); } clearLeds(); // Turn off toggling of pin 11 FrequencyTimer2::disable(); // Set refresh rate (interrupt timeout period) FrequencyTimer2::setPeriod(2000); // Set interrupt routine to be called FrequencyTimer2::setOnOverflow(display); setPattern(pattern);}void loop() { pattern = ++pattern % numPatterns; slidePattern(pattern, 60);}void clearLeds() { // Clear display array for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { leds[i][j] = 0; } }}void setPattern(int pattern) { for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { leds[i][j] = patterns[pattern][i][j]; } }}void slidePattern(int pattern, int del) { for (int l = 0; l < 8; l++) { for (int i = 0; i < 7; i++) { for (int j = 0; j < 8; j++) { leds[j][i] = leds[j][i+1]; } } for (int j = 0; j < 8; j++) { leds[j][7] = patterns[pattern][j][0 + l]; } delay(del); }}// Interrupt routinevoid display() { digitalWrite(cols[col], LOW); // Turn whole previous column off col++; if (col == 8) { col = 0; } for (int row = 0; row < 8; row++) { if (leds[col][7 - row] == 1) { digitalWrite(rows[row], LOW); // Turn on this led } else { digitalWrite(rows[row], HIGH); // Turn off this led } } digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)}
[Get Code]

Sample code for "Life" (needs FrequencyTimer2 library):

/* * Conway's "Life" * * Adapted from the Life example * on the Processing.org site * * Needs FrequencyTimer2 library */#include byte col = 0;byte leds[8][8];// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)int pins[17]= {-1, 5, 4, 3, 2, 14, 15, 16, 17, 13, 12, 11, 10,9, 8, 7, 6};// col[xx] of leds = pin yy on led matrixint cols[8] = {pins[13], pins[3], pins[4], pins[10], pins[06],pins[11], pins[15], pins[16]};// row[xx] of leds = pin yy on led matrixint rows[8] = {pins[9], pins[14], pins[8], pins[12], pins[1],pins[7], pins[2], pins[5]};#define DELAY 0#define SIZE 8extern byte leds[SIZE][SIZE];byte world[SIZE][SIZE][2];long density = 50;void setup() { setupLeds(); randomSeed(analogRead(5)); for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { if (random(100) < density) { world[i][j][0] = 1; } else { world[i][j][0] = 0; } world[i][j][1] = 0; } }}void loop() { // Display current generation for (int i = 0; i < SIZE; i++) { for (int j = 0; j < SIZE; j++) { leds[i][j] = world[i][j][0]; } } delay(DELAY); // Birth and death cycle for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { // Default is for cell to stay the same world[x][y][1] = world[x][y][0]; int count = neighbours(x, y); if (count == 3 && world[x][y][0] == 0) { // A new cell is born world[x][y][1] = 1; } if ((count < 2 || count > 3) && world[x][y][0] == 1) { // Cell dies world[x][y][1] = 0; } } } // Copy next generation into place for (int x = 0; x < SIZE; x++) { for (int y = 0; y < SIZE; y++) { world[x][y][0] = world[x][y][1]; } }}int neighbours(int x, int y) { return world[(x + 1) % SIZE][y][0] + world[x][(y + 1) % SIZE][0] + world[(x + SIZE - 1) % SIZE][y][0] + world[x][(y + SIZE - 1) % SIZE][0] + world[(x + 1) % SIZE][(y + 1) % SIZE][0] + world[(x + SIZE - 1) % SIZE][(y + 1) % SIZE][0] + world[(x + SIZE - 1) % SIZE][(y + SIZE - 1) % SIZE][0]+ world[(x + 1) % SIZE][(y + SIZE - 1) % SIZE][0]; }void setupLeds() { // sets the pins as output for (int i = 1; i <= 16; i++) { pinMode(pins[i], OUTPUT); } // set up cols and rows for (int i = 1; i <= 8; i++) { digitalWrite(cols[i - 1], LOW); } for (int i = 1; i <= 8; i++) { digitalWrite(rows[i - 1], LOW); } clearLeds(); // Turn off toggling of pin 11 and 3 FrequencyTimer2::disable(); // Set refresh rate (interrupt timeout period) FrequencyTimer2::setPeriod(2000); // Set interrupt routine to be called FrequencyTimer2::setOnOverflow(display);}void clearLeds() { // Clear display array for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { leds[i][j] = 0; } }}// Interrupt routinevoid display() { digitalWrite(cols[col], LOW); // Turn whole previous column off col++; if (col == 8) { col = 0; } for (int row = 0; row < 8; row++) { if (leds[col][7 - row] == 1) { digitalWrite(rows[row], LOW); // Turn on this led } else { digitalWrite(rows[row], HIGH); // Turn off this led } } digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)}

Step 16: Uploading the Arduino Code

1. Once the Arduino code has compiled successfully without any errors, go to Tools>>Board: "Arduino: **** " and select Arduino/Genuino Uno (unless you are using a different board).

2. Click "Upload Code" (second button from the left on the menu bar). This will upload the current program onto the Arduino board which controls the LED.

As I have emphasized before, this is your project, and I strongly encourage you to make a creation unique to your own personal style, so change the code and create different patterns in the loop, where 0 is off and 1 is on.

Step 17: Thank You and Please Vote!

If you are reading this, then you have made it to the end, and hopefully have exercised your art and electronic skills in making your own LED Matrix Sunglasses.

Thank you for taking your time in reading this! I have entered this 'ible in the LEDs contest, so if you enjoyed reading and/or making it, please vote for me in the contest.


Thank you from Tech Martian !!!

Lights Contest 2017

Participated in the
Lights Contest 2017