0

Raspberry Christmas Hat

What’s the story Rory?

Today I want to show some Christmas project ideas using Hats. Yes, another blog about Raspberry PI.

Thanks to their GPIO headers, most Pi computers can connect to devices called HATs, which stands for Hardware Attached on Top.

Theses are the Hats that I have and they came from ThePiHut

Christmas Tree Programmable KitLink

I think this hat comes in 3 different sets, one just with white LEDs, one with just red LEDs and one with mixed white and red LEDs and you can find the Pre-soldered version as well.
From the Python API you can get the GPIO numbers to use with PI4j

SnowPiLink

The SnowPi is a discontinued item, but you can find it in ThePiHut.
From the Python API you can get the GPIO numbers to use with PI4j

During 2020 there was another successful Kickstarter project for the SnowPi RGB. This is a new version of the Snowman. There is no soldering required and it now has color NeoPixels instead of single color LEDs.

3D Xmas Tree for Raspberry PiLink

After a while, they release an RGB version as well. Like all the others you can find the Pre-soldered version as well.
From the code sample, you can get the GPIO numbers to use with PI4j

Raspberry Pi Christmas Tree StarLink

From the Python API you can get the GPIO numbers to use with PI4j

The idea here is that all hats are just boards with some LEDs, and this makes the project like an electronics project for blinking LEDs.
We can use the PWM idea, “Pulse Width Modulation” that I already explained here, but let me explain from the LEDs perspective.

From Wikipedia

The term duty cycle describes the proportion of ‘on’ time to the regular interval or ‘period’ of time; a low duty cycle corresponds to low power because the power is off for most of the time. Duty cycle is expressed in percent, 100% being fully on. When a digital signal is on half of the time and off the other half of the time, the digital signal has a duty cycle of 50% and resembles a “square” wave. When a digital signal spends more time in the on state than the off state, it has a duty cycle of >50%. When a digital signal spends more time in the off state than the on state, it has a duty cycle of <50%. Here is a pictorial that illustrates these three scenarios.

You can find examples and samples for all Hats in Python, but because I support the #JavaOnRaspberryPi idea, let’s see how to use them with Java.
Remember to use the hashtag #JavaOnRaspberryPi on Twitter to show the world Raspberry Pi with Java.

PI4J
You can check my post to start with PI4J but for these hats what you need to understand is the Pwm Example

1
2
3
com.pi4j.wiringpi.Gpio.pwmSetMode(com.pi4j.wiringpi.Gpio.PWM_MODE_MS);
com.pi4j.wiringpi.Gpio.pwmSetRange(100);
com.pi4j.wiringpi.Gpio.pwmSetClock(500);

The idea is that “setPwm()” can be 0, to turn off, 100, to turn on and any value between 0 and 100 to create a fade.

1
2
3
setPwm(0)
setPwm(100)
setPwm(value);

Now you can not just turn on and off, but you can also pulse, blink and add a fade effect.

Here is my forest project from 2018.

Of course, you can do some Christmas ideas with any other hat.

Sensehat http://www.igfasouza.com/blog/sense-hat/

You can create your Christmas tree using my Micronaut example. GitHub Or just using this.

E-ink display

I know that 4tronix has some Christmas Micro Bit hats and people did some hack around to use with a Raspberry PI, But If you know any other Christmas Hat, please let me know in the comments.

As a good developer, I always get confused about Christmas and Halloween as 25 Dec is equal to 31 Oct

PumpkinPi https://thepihut.com/products/halloween-pumpkinpi-for-raspberry-pi

Some other Christmas ideas
https://www.raspberrypi.org/blog/tag/christmas/

Leave a Reply

Your email address will not be published. Required fields are marked *