Introduction: LED Nintendoscape
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com). We will be covering how to make an awesome Nintendo mushroom themed display that contains an RGB LED matrix and a rotating mushroom in a warp tube. All of the electrical components in this project are controlled via an Arduino Uno R3.
Step 1: Components Needed:
3D Printed Parts:
- 1 Case (bottom and lid)
- 2 Mushrooms
- 1 Warp Tube
- 1 Question Block
Electrical:
- 1 Arduino Uno R3 clone
- 1 USB Cable
- 1 Stepper Motor
- 1 ULN2003 Motor driver module
- 1 Breadboard
- 1 Bundle breadboard jumper wires
- 6 Female to female cables
- 1 IR receiver
- 1 Remote
- 1 Adafruit NeoPixel NeoMatrix 8x8 - 64 RGB LED Pixel Matrix
- Soldering iron, flux and solder
Other Components:
- Electrical Tape
- Hot Glue
- Plastic Spray Paint Primer
- Acrylic Paint
- Dowel Rod
- Drill and Dremel
Step 2: 3D Printed Parts
As shown in the above picture, several parts were printed out on a 3D printer. The LED matrix mounts to the front of the question mark block and can be secured with electrical tape or hot glue from behind. Holes were drilled with an electric drill under the question mark block and under the warp tube on the black box lid. This was done to pass through wires for the matrix and IR sensor. A small hole was drilled in the front of the warp tube and the IR sensor was secured from behind with electrical tape. This can be seen on the first picture of the instructable. The hole used to pass through wires for the IR sensor also allows a dowel rod to pass through which allows the mushroom to rotate. On the back of the box, a dremel was used to notch out a place for the cord to pass through at the joint where the lid meets the base. This is optional and can be placed in a location of your choice.
The video above shows the rotation of the mushroom in the tube and the general rendered output of the 3D CAD files when assembled together.
The zip file below contains all the parts necessary to 3D print this project. The file contains the black box (minus the screws), a mushroom, a warp tube, and the question mark block. Two of the mushroom prints were used in this project; one rotates above the warp tube and one remains stationary on the block. The parts can be printed in color or painted later as described at the end of this instructable.
Attachments
Step 3: Electrical Components
The schematic above shows how the electrical components are wired together complete with the pin connections to the Arduino. There are a few minor differences from the parts available to create the schematic and those used in the project which will be discussed here.
The motor control module chip used in the project is identical to that shown on the breadboard, however the chip in the project was mounted to a motor control board which was provided in the course kit. The picture on the bottom-middle shows a picture of the board with the pinout and connections from the motor to the board, power and the Arduino.
For the LED Matrix, the picture on the bottom left on the left shows the back of the matrix board with the three output pins. These connections will need to be soldered on using breadboard jumper wires or wires of your choice. They can then be connected to the power and ground on the breadboard and pin 6 on the Arduino.
The bottom right picture shows the actual setup used in the project and how the connections appear once wired together on the Arduino and breadboard and placed in the box.
Step 4: Arduino Code
In order for our project to run we need to push code to the Arduino to control the electrical components. Libraries are included in a zip file, and the folders inside must be placed in the main Arduino library folder on your computer after unzipping. Included are libraries for the IR sensor, stepper motor, and the LED display from Adafruit. The attached zip file titled Arduino Code contains the folder with the Arduino sketch needed to run the code. This simply needs to be flashed to the Arduino in order for the code to run.
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h> #include <Adafruit_NeoPixel.h> #include <StepperAK.h> #include <IRremote.h>#define PIN 6 //LED Matrix input on Pin 6
#define gearratio 64 //1:64 gear ratio for stepper motor #define BOARDCOUNT 1 // number of LED matrices Adafruit_NeoPixel strip = Adafruit_NeoPixel(64 * BOARDCOUNT, PIN, NEO_GRB + NEO_KHZ800); //Sets up the number of LED nodes double brightness = .1; // reduce brightness for the LED Matrixconst int stepsPerRevolution = 2048; //2048 steps turn the motor one revolution Stepper myStepper(stepsPerRevolution, A0, A1, A2, A3); // 4-wire stepper on pins A0-A3
int RECV_PIN = 9; //IR Receiver connected to Pin 9 IRrecv irrecv(RECV_PIN); //Create a IR receiver object decode_results results; //Create a decode_results object
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(8, 8, PIN, //Initiates an 8x8 LED Matrix NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE, NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = { matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) }; //Defines LED Matrix Colors
The code works by establishing what libraries are needed and defining all the pins used and variables required. It then dims the brightness of the LED matrix, sets up the motor revolution, and creates an object for the IR sensor. The LED Matrix is then initialized and the colors are set up.
void setup() {
myStepper.setSpeed(0.15*gearratio); //the motor appears to be geared down 1/64, //meaning that the speed needs to be set 64x. irrecv.enableIRIn(); //Enables the IR device matrix.begin(); //Starts the LED Matrix with a blank display matrix.setTextWrap(false); matrix.setBrightness(40); matrix.setTextColor(colors[0]); }
int x = matrix.width(); //Establishes X as the matrix width int pass = 0; //Establishes pass variable int flag=0; //variable to establish when the device is powered on via remote
In the setup section, the stepper gear ratio is set up to control the speed, the IR sensor is enabled and the matrix is set to a blank display. Several variables are also established which are used later for the matrix and to determine when the power button was pressed.
void loop() {
if (irrecv.decode(&results)) {//has a transmission been received? if (results.value == 3584887633){ //If the power button is pressed the flag variable changes and the main program executes flag=1; } } //irrecv.resume(); // Receive the next value from the IR Sensor
The project starts with a blank LED display, and the IR sensor is activated and waits for the power button to be pushed. After the power button is pushed, the main loop of the project is entered. The number in the results.value space is the decoded result from the power button on a Panasonic Audio System remote, however another remote can be used annd you will need to decode the remote first in order to obtain the numerical numbers associated with your buttons.
if (flag==1) //If flag is equal to 1, then the power button was pressed
{ if (irrecv.decode(&results)) {//has a transmission been received? Serial.println(results.value);//If yes: interpret the received commands... if (results.value == 2354352215){ //If the "-" Button is pressed do the following: matrix.fillScreen(0); //Clears the LED matrix matrix.setCursor(2, 0); //Sets the cursor position matrix.setTextColor(colors[2]); //Sets the text color matrix.print(F("?")); //Prints the "?" character to the screen matrix.show(); //Enables the matrix delay(100); //Delays the matrix myStepper.step(stepsPerRevolution); //Rotates the stepper motor
If the "+" or "-" button is hit on the remote, the mushroom rotates in opposite directions and a question mark is displayed on the matrix. The example code above shows the process for the "-" button being pressed, and the code for the "+" is nearly identical.
if (results.value == 3584887633){ //If the power button is pressed a Rainbow lights up
colorWipe(strip.Color(brightness * 255, 0, 0), 5); // Red colorWipe(strip.Color(0, brightness * 255, 0), 5); // Green colorWipe(strip.Color(0, 0, brightness * 255), 5); // Blue rainbow(5); rainbowCycle(5); } irrecv.resume(); // Receive the next value from the IR Sensor } matrix.fillScreen(0); //If no input on the remote, clear the matrix screen matrix.setCursor(x, 0); //Sets the cursor position to variable 'x' matrix.print(F("MAKE")); //Prints the word "Make" to the matrix if(--x < -36) { //Cycles the cursor position to make text appear to scroll x = matrix.width(); if(++pass >= 3) pass = 0; //Cycles through three colors for the text display matrix.setTextColor(colors[pass]); } matrix.show(); //Prints text to matrix delay(100); //Establishes a delay} }
Whenever the power button is pressed a rainbow appears and cycles through several colors and patterns. After this process, the word "MAKE" then scrolls across the screen in rotating colors unless another button is hit on the remote. If the power button is hit again the rainbow display repeats. This process repeats indefinitely as long as the Arduino remains powered.
The code below are functions that are called in order to execute the rainbow display that appears when the power button is pressed.
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) { for(uint16_t i=0; ivoid rainbow(uint8_t wait) { uint16_t i, j;
for(j=0; j<256; j++) { for(i=0; i
// Slightly different, this makes the rainbow equally distributed throughout void rainbowCycle(uint8_t wait) { uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel for(i=0; i< strip.numPixels(); i++) { strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255)); } strip.show(); delay(wait); } } // Input a value 0 to 255 to get a color value. // The colours are a transition r - g - b - back to r. uint32_t Wheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(brightness * WheelPos * 3, brightness * (255 - WheelPos * 3), 0); } else if(WheelPos < 170) { WheelPos -= 85; return strip.Color(brightness * (255 - WheelPos * 3), 0, brightness * WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, brightness * WheelPos * 3, brightness * (255 - WheelPos * 3)); } }
Step 5: Assembly and Finishing Touches
For coloring the printed components, the best results were obtained by spray painting the pieces with a plastic primer. Once the primer has dried, color was added with acrylic paint to the mushrooms and to the "?" on the side of the block.
For the assembly of the project, hot glue is going to be our best friend! It hold the plastic components together extremely well, yet you are able to peel the pieces apart again if needed due to a mistake. The IR sensor was taped into position in the warp tube first and the wires secured to the sides of the tube with tape. The dowel rod was glued to the stepper motor first, and the stepper motor was secured with electrical tape underneath the warp tube. The mushroom on the block and on the dowel rod were hot glued into place. The LED matrix was secured to the front of the block with electrical tape on the back and both the block and warp tube were hot glued into place.
The wires were run down the holes drilled into the lid of the black box and connected in place to the Arduino and breadboard. The Arduino, breadboard and motor control circuit were placed in the box and the power cord threaded through the notch on the back. This gives a clean look to the final project with no exposed wiring. The video above shows the final project in working order.