Skull: Halloween 2020


The idea  

Decorations are simply part of Halloween. And such a cool skull in the window would look awesome. But only if people would notice it too. In the dark the effect is rather manageable. Of course,  it would be better if the eyes would glow. Even better if they don't just glow but blink or fade. And as irregular as possible. So I grabbed my soldering bit and my PC again and made a new project.

The Hardware 

For the project, I had almost everything still at home.  

First of all, you need a skull. You can get it on Amazon or in some well-sorted party stores. Mine has a realistic size, so you can see it standing in the window from outside.
Then you need 2 LEDs, best in red color and nice and bright. 

As a control unit I used a DigiSpark (Digistump)


Of course, any other Arduino variant is also possible.

For the circuit you still need current limiting series resistors a' 220Ohm for the LEDs and some cable.

For the power supply different methods can be used. The easiest way is of course a powerbank with a USB extension cable. But you have to be careful, because the power consumption can be too **low** for some powerbanks, so that they can be switched off after a short time or even not be switched on at all. 

Another option is a simple battery box for 3xAAA (if equipped with 1.5V) or 4xAAA, if with rechargeable batteries (1.2V). This one is already available with switch and cable.

The wiring is quite simple.


The Battery Box is connected to GND and 5V. (With a USB power supply you don't need this).  At the cathodes of the two LEDs you have to first solder a piece of cable to the Ground connector of the battery box. 

First the series resistor (usually 220Ohm at 2.2V LED forward voltage) is soldered to the anodes of the LEDs. Then a cable is soldered to the resistor and connected to the P0 and P1 connectors of the Digispark. If you want to use a different Arduino, please note that the outputs must support PWM. With the Arduino Uno or Nano you can use the outputs 5 and 6. Just remember to  change the corresponding constants at the top of the program. (`OUT_1` and `OUT_2`)

Now you can carefully cut out a fold-out lid from the bottom of the head with a carpet knife. Then you drill a 5mm hole in the middle of each eye and plug in the LEDs with the cables from the inside. The rest of the electronics including the battery can then be stored in the skull.

The head is slightly transparent and the red LED on my Digispark is also very bright. Since this LED also uses PIN 1, the whole head glows in the same rhythm as the eyes. If you want to have this independently, you can of course solder the eye LED from PIN 1 to another PIN and change it in the program. Another PWM output is provided by PIN 4 at the Digispark.

The Software

Digispark Installation 

First you have to install the correct Windows driver for the Digispark.

To do this, download from the site: [https://github.com/digistump/digiStumparduino/releases
the file DigiStump.Drivers.zip. 

Unpack this file in any directory and then execute the file DPinst64.exe (Windows 64 Bit, for 32 Bit DPinst.exe). You just simply have to follow the instructions of the installation program. 

The next step is to add the Digispark to the board manager of the Arduino IDE.  You can easily do this by adding the following URL to the list "additional board manager URLs" in the preferences. If you already have additional board manager URLs there, please do not forget the comma.

> `http://digistump.com/package_digistump_index.json` 


Now you can search for the Digistump AVR Boards entry under Tools/Board/Board manager. It contains the board. Then you can install it.


The last step of the hardware setup is to select the Digispark (default 16.5MHz) as active board. 


So far we are finished with the installation. A special feature of Digispark is that you do not need a port. If you want to upload a program, this only works if the dwarf (micro controller) has just been plugged/started into the USB port. When uploading, the following instruction appears in the console:


At this point you need to plug the Digi into the USB port.  

The whole thing is of course easier if you have a switchable USB hub. Then you don't have to plug it in and out. 

The Code 

I don't have to say much about the program. Both outputs are PWM capable, i.e. you can feed them with values between 0 and 255. But the program does not fade out completely, but starts with a minimal value. And also the lap time is chosen randomly from an interval. The program now fades the two LEDs up and down simultaneously in this random interval. 



/*
Skull
This is a tiny little program for fading red eyes on a skull for Halloween.
Designed for a Digispark or Tiny85

Copyright 2020 Wilfried Klaas

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const byte OUT_1 = 0;
const byte OUT_2 = 1;
const byte MAX = 255;
const byte MIN = 16;
const byte DELAY= 7;
const word ROUNDTIME_MIN = 500;
const word ROUNDTIME_MAX = 1500;

bool up = true;
byte bright = MIN;
byte level = MAX;
word delayTime = 7;
word roundTime = ROUNDTIME_MIN + (ROUNDTIME_MAX - ROUNDTIME_MIN) / 2;

void setup() {
    pinMode(OUT_1, OUTPUT);
    pinMode(OUT_2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    analogWrite(OUT_1, bright); // turn the LED on (HIGH is the                                                            // voltage level)
    analogWrite(OUT_2, bright); // turn the LED on (HIGH is the                                                            // voltage level)
    if (bright >= level) {
        up = false;
    }
    if (bright <= MIN) {
        up = true;
        level = random(16, MAX);
        roundTime = random(ROUNDTIME_MIN, ROUNDTIME_MAX);
        delayTime = roundTime / (level - MIN);
    }
    if (up) {
        bright++;
    } else {
        bright--;
    }
    delay(delayTime);
}

 

Conclusion 

Have fun building this project. 

I hope you also enjoyed this short blog. See you in the next blog series .

Wilfried Klaas

Specials

Einen Kommentar hinterlassen

Alle Kommentare werden vor der Veröffentlichung moderiert

Aanbevolen blog berichten

  1. Installeer ESP32 nu van de raad van bestuur
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP Programmeren via Wi-Fi