Godzilla!! Now in Night Light Form
by JohnZenRider in Circuits > Arduino
1127 Views, 3 Favorites, 0 Comments
Godzilla!! Now in Night Light Form
Who doesn't love this famous Japanese monster??!! My son does!! (Well, all the men in our family do) So for Christmas in 2019, the whole family got together and made him a large Godzilla with lights and sounds. After purchasing a 3D model with STL files, they needed to be modified for the inclusion of the LED lights and to enlarge the print. This project uses 3D printing, LED lights, and a microcontroller.
Supplies
Arduino Nano or any Arduino or RaspberryPi Pico board. I had a Nano handy so I used that.
Breadboard
jumper wires
DFPlayer Mini MP3 breakout board
An 8ohm 3-watt speaker. If you want to set up stereo, then get 2 of the speakers.
A 5V at least 3Amp power supply. This is for powering the LEDs since the Nano and DFPlayer Mini take only a few milliamps to work.
330 ohm, 680 ohm, 1K ohm and 10K ohm resistors
2000 uf Electrolytic capacitor
1 5V Addressable LED strip. I ended up using 46 count LEDs. This strip was a 60/meter one. Wanted more lights closer together for this. (Note* You will see in the code that I have it set for 44 because, during the installation process, I shorted out 2 of them at the beginning of the strip. Beware the heat gun or use a better wire.)
Godzilla model to modify. We used the model from Gamboy and my son who is a graphic artist edited it in Blender. Needed to make the spines removable so we can install the LED light strip.
You will need paint for the eyes, mouth, nails, and body.
Glue gun
The platform he stands on was made from 3/4 inch plywood, glued and screwed together, and then stained with an antique walnut finish.
The Model
We needed a good model to modify and found one on Gambody. This link is the model that we used. Gambody STL files of Heisei Godzilla for 3D Printer
Next, my son who is a graphic artist took the model and combined several parts. He had to use Blender to do this work and had to smooth out several pieces to close up polygons so that they would print correctly.
Once the parts were made into larger parts like each leg was made up of several parts. All the parts were combined to form the left leg and the right leg respectively. The upper body was made into 1 whole part. The tailpieces were combined to form 2 parts. Then the first part of the tail, the one closest to the body, had the spines cut out.
In the picture showing the Left leg, a hole had to be added to the leg starting at the bottom and going to the connecting joint so we can run the wires for the LED lights through it.
Once the parts were completed, they were exported as stl files so they could be sliced.
3D Printing the Parts
Use your slicer to create the files to print. To make it big enough, we enlarged the files by 160%. This would give us a model that was a little over 14" high. Printing took us about 9 days to print everything out.
Body and legs should be printed with a matte black PLA.
For the spines and both tail sections, use transparent PLA. The tail sections will get painted such that all but the spines will be black. We want to spines to not have color since we are going to have LED lights attached under the spines.
My youngest son and wife detailed the model by painting the mouth with red paint for the tongue.
Then painted each tooth white. This completed the mouth.
The eyes were next. First white and then a Sharpie was used to make the iris.
Each fingernail and toenail was painted white to make them stand out from the rest of the foot.
The body and legs were brushed with some matte black to take the shine down.
Then all the black parts were dry brushed with a medium to light grey to highlight the details in the skin.
After the LEDs are installed, the spines are glued into place using hot melt glue. Then matte black paint is used to blend the spines into the body. Some of the matte black paint was dry brushed on the spines to add detail.
We don't have any pictures of the printing process or the actual detailing part. If we do another model, we will add pictures and videos to this document.
Sound Bites
To get the sound for the tail charging and then a roar and the fire breath blast, we pulled the sound from the movie. Then used an audio editing program to cut and paste and combine the parts into a single file. This file was then exported as an MP3. A 2GB Micro SD card was formatted as Fat32.
The files have to be named a certain way. They have to be prefixed with a 4 digit number and then a Dash and whatever name you want to give the file. The numbered files are how the sketch calls the sound files to play.
See this link for a more detailed overview of how the DF Player Mini is wired up and how to prepare the microSD card for use in the DF Player Mini breakout board. Wiring DFPlayer Mini (MP3 Module) to Arduino. Stereo/Mono Diagrams. - Circuit Journal
We used this one for our project.
Copy this file to the root of the microSD card.
Downloads
Wiring
Please don't judge me. I used an old breadboard and some miscellaneous parts to build this circuit. The capacitor I used was salvaged from some junk electronics.
Since I had an Arduino Nano on hand, I used it for the project. You could use any microcontroller to make this work. But know that I used the FastLED library for Arduino. If you use say the Raspberry Pi Pico, I haven't checked to see if there is a LED library available to help simplify the special effects.
For power, a 5.5mm x 2.5mm female connector was wired to the breadboard.
LEDs are powered from the breadboard power rail with the 2000 microfarad capacitor in series with the positive rail lead. We want this in place so that when power is plugged in, the LED lights won't flash.
A voltage divider is needed on the DF Player's TX pin since it is not 5V tolerant. So we use a 680Ohm resistor inline with Digital pin 10 and then a 1K resistor to Ground and the TX pin of the DF Player connected between the two resistors. This reduces the voltage to a tolerable level for the DF Player mini.
The input pin for the button has a 10K pull-down resistor attached. This ensures the proper detection of a high or low state.
I originally had 46 LEDs but burned out 2 of them when installing the LED lights into the model. This was because we used a heat gun to melt the tail enough to open a slot for the wires. This wouldn't have been a problem if I had used better wires. I was using wire I pulled out of a section of networking cable. The wire works great but is a bit thin and the insulation easily melts with just a little bit of heat.
Once everything has been wired up, power on the system. Nothing will be happening just yet until the Nano is programmed.
The Code
Below is the code for running the project.
Debouncing was used to prevent the detection of multiple button pushes.
The bold section is where you set the number of LEDs in the strip. 44 is how many can fit in the model.
A word of caution. If you keep a computer connected to the Nano while testing, this will change the timing. The LEDs will light slower than the sound is playing.
After the process is complete, the lights will stay on but at half brightness to become a night light. Pressing the button again will turn off the night light.
The Underlined and Italics line (const int nextLED = 100) is for changing the rate the pixels light up along the strip. The higher the number the slower they light. The lower the number, the faster they light up.
#include "FastLED.h" // FastLED library.
#include <SoftwareSerial.h>
#include <DFPlayerMini_Fast.h>
SoftwareSerial mySerial(10, 11); // RX, TX
DFPlayerMini_Fast myMP3;
#if FASTLED_VERSION < 3001000
#error "Requires FastLED 3.1 or later; check github for latest code."
#endif
// Fixed definitions cannot change on the fly.
#define LED_DT 3 // Data pin to connect to the strip.
#define LED_TYPE WS2812 // Using APA102, WS2812, WS2801. Don't forget to modify LEDS.addLeds to suit.
#define NUM_LEDS 44 // # of LEDS in the strip
#define COLOR_ORDER GRB // I had to change this for my strip if your color is off then you know.
// Global variables can be changed on the fly.
uint8_t max_bright = 255; // Overall brightness definition. It can be changed on the fly.
long mycount = 0;
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
const int setpoint = NUM_LEDS * 107;
const int nextLED = 100; //this is to delay between LEDS
int timer = setpoint + 1000; //Set the timer beyond what the setpoint is. This will make the LEDs not come on
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
// Variables will change:
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin
// . int trackOneLeng = 20625; // This is the length of the first track
bool pulseDone = true; // Set this to true so that the pulse generator won't trigger
// the following variables are unsigned longs because the time, measured in
// milliseconds, will quickly become a bigger number than can be stored in an int.
unsigned long lastDebounceTime = 0; // the last time the output pin was toggled
unsigned long debounceDelay = 50; // the debounce time; increase if the output flickers
int inightlight = 0; // Set the nightlight to zero. this will be set to
int busy = 1; // This means that it is NOT busy.
void setup() {
Serial.begin(57600); // Initialize serial port for debugging.
delay(1000); // Soft startup to ease the flow of electrons.
pinMode(buttonPin, INPUT);
pinMode(4, INPUT); // Reading the playing state of the pin
mySerial.begin(9600); //Initialize the serial for the DFPlayer Mini
myMP3.begin(mySerial);
Serial.println("Setting volume to 10"); //This is being set at 10 since we are using an applified speaker
myMP3.volume(22);
delay(2000); // Delay 1 seconds for the player to register
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2801 or APA102
// LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812
FastLED.setBrightness(max_bright);
FastLED.clear();
FastLED.show();
//set_max_power_in_volts_and_milliamps(5, 500); // FastLED Power management set at 5V, 500mA.
Serial.println("Setup complete. Starting the loop now.");
} // setup()
void loop(){
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);
int busy = digitalRead(4);
//Serial.print("Button state: ");
//Serial.println(reading);
// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
} //if reading lastbuttonstate
if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer than the debounce
// delay, so take it as the actual current state:
// if the button state has changed:
if (reading != buttonState) { // . Set the button state to what was last read
buttonState = reading;
// only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) { // . there was a change in the state so do the work
if (inightlight == 0) { // is nightlight off? yes, start process
inightlight=1;
timer = 0;
//Serial.println("Checking mp3 playing"); // Check to see if the mp3 is playing
if(busy == 1){ // not playing an mp3 start the process
Serial.println("Starting mp3");
myMP3.play(1);
} //if mp3 is playing
}
else { // nightlight is 1 to turn things off by making it zero
inightlight = 0;
Serial.println("Turn off the nightlight");
} // else nightlight reset
} //if buttonstate
} // if reading buttonstate
} //if millis is not debouncing
if (timer <= setpoint){ // The timer is not reset so don't activate the LEDS.
setcolors();
}
if (timer >= setpoint && busy == 0 ) { // Check to see if the mp3 is still playing and if so, then pulse.
if (busy == 0) { // If the sound is still playing then send to pulse
Pulse(); // Call the pulsing LEDs
} // mp3 playing
} // if timer and playing mp3
if (timer >=setpoint && busy == 1) { // Done with the fade and not playing mp3 anymore, now test for nightlight
fill_solid(leds, NUM_LEDS, CHSV(171,255,175)); // Set the overall brightness
} // if timer done and no playing mp3
if (inightlight == 0 && busy == 1 ){ // playing of the MP3 is over
FastLED.clear();
} // if inightlight .
FastLED.show();
// save the reading. Next time through the loop, it'll be the lastButtonState:
lastButtonState = reading;
} // loop()
void setcolors(){
static long mycount = 0;
if(timer == 0){
mycount = mycount*0;
Serial.println("Reset mycount");
} // if timer = 0
for (int i=0; i< NUM_LEDS; i++)
{
long temp = mycount / (nextLED*i+1); // Each LED starts to light up after the previous one has a brightness of 8. Watch out for div0 though.
if (temp >0) { // Once an LED is lit, take the mycount value and subtract the LED location to get the resulting brightness
temp = temp+mycount-nextLED*i;}
temp = constrain(temp,0,255); // Keep the absolute value from going over 255
leds[i] = CHSV(171,255,temp);
}// for loop
mycount++;
timer = mycount;
} // setcolors()
void Pulse(){
int nbrightness = 0;
int nfadeAmount = 5;
int playing = digitalRead(4);
do{
playing = digitalRead(4);
for(int i = 0; i < NUM_LEDS; i++ )
{
leds[i].setRGB(0,255,250); // Set Color HERE!!!
leds[i].fadeLightBy(nbrightness);
}
FastLED.show();
nbrightness = nbrightness + nfadeAmount;
// reverse the direction of the fading at the ends of the fade:
if(nbrightness == 150 || nbrightness == 255)
{
nfadeAmount = -nfadeAmount ;
}
delay(2); // This delay sets speed of the fade. I usually do from 5-75 but you can always go higher.
} while(playing == 0);
// . pulseDone = false; //reset the trigger so this won't get run again
}
Downloads
The Base
The base was made from leftover plywood we had in the shop.
It measures between 12" x 17" and 2 inches tall.
A hole was drilled for the button and a 3D printed plate for the button was mounted to the top.
A 3D printed plate was mounted to the back where the AC adapter connects.
A hole is drilled in the top for the speaker wires.
A small hole is drilled in the top. This is where Godzilla's foot will be mounted and the wires for the LED lights threaded through. Godzilla is mounted to the base with hot melt glue and two screws, one in each foot.
The Future
So what is in store for the Godzilla project in the future??
As I get time, I will print speaker holders disguised as damaged buildings. He wants to get more items added to the model like damaged buildings with optic fiber simulating fires or electrical shorts.
My son also wants it to where you press the button twice in a row, it will play the Orca Alpha sound bite as heard in the movie Godzilla: King of the Monsters. The lighting effect will be a pulse that runs to the head and the tail from the center of the model. It will play for about a minute and then goes quiet and the lights power off.
Since there is a microcontroller at the heart of the project, the possibilities are endless!!
Whatever I do to enhance the model, I will add to this writeup.