Tag Archives: how-to

Laser-engraved Raspberry Pi hologram

via Raspberry Pi

Inspired by an old episode of Pimoroni’s Bilge Tank, and with easy access to the laser cutter at the Raspberry Pi Foundation office, I thought it would be fun to create a light-up multi-layered hologram using a Raspberry Pi and the Pimoroni Unicorn pHAT.

Raspberry Pi layered light

Read more –

Break it to make it

First, I broke down the Raspberry Pi logo into three separate images — the black outline, the green leaves, and the red berry.

RASPBERRY PI HOLOGRAM RASPBERRY PI HOLOGRAM RASPBERRY PI HOLOGRAM

Fun fact: did you know that Pimoroni’s Paul Beech designed this logo as part of the ‘design us a logo’ contest we ran all the way back in August 2011?

Once I had the three separate files, I laser-engraved them onto 4cm-wide pieces of 3mm-thick clear acrylic. As there are four lines of LEDs on the Unicorn pHAT, I cut the fourth piece to illuminate the background.

RASPBERRY PI HOLOGRAM

To keep the engraved acrylic pieces together, I cut out a pair of acrylic brackets (see above) with four 3mm indentations. Then, after a bit of fiddling with the Unicorn pHAT library, I was able to light the pHAT’s rows of LEDs in white, red, green, and white.

RASPBERRY PI HOLOGRAM

The final result looks pretty spectacular, especially in the dark, and you can build on this basic idea to create fun animations — especially if you use a HAT with more rows of LEDs.

Iterations

This is just a prototype. I plan on building a sturdier frame for the pieces that securely fits a Raspberry Pi Zero W and lets users replace layers easily. As with many projects, I’m sure this will grow and grow as each interaction inspires a new add-on.

How would you build upon this basic principle?

Oh…

…we also laser-engraved this Cadbury’s Creme Egg.

The post Laser-engraved Raspberry Pi hologram appeared first on Raspberry Pi.

Coding Space Invaders’ disintegrating shields | Wireframe #9

via Raspberry Pi

They add strategy to a genre-defining shooter. Andrew Gillett lifts the lid on Space Invaders’ disintegrating shields.

Wireframe 9 Space Invaders

Released in 1978, Space Invaders introduced ideas so fundamental to video games that it’s hard to imagine a time before them. And it did this using custom-made hardware which by today’s standards is unimaginably slow.

Space Invaders ran on an Intel 8080 CPU operating at 2MHz. With such meagre processing power, merely moving sprites around the screen was a struggle. In modern 2D games, at the start of each frame the entire screen is reset, then all objects are displayed.

For Space Invaders’ hardware, this process would have been too slow. Instead, each time a sprite needs to move, the game first erases the sprite from the screen, then redraws it in the new position. The game also updates only one alien per frame — which leads to the effect of the aliens moving faster when there are fewer of them. These techniques cut down the number of pixels which need to be updated each frame, from nearly 60,000 to around a hundred.

Wireframe 9 Space Invaders

One of Space Invaders’ most notable features is its four shields. These provide shelter from enemy fire, but deteriorate after repeated hits. The player can take advantage of the shields’ destructible nature — by repeatedly firing at the same place on a shield’s underside, a narrow gap can be created which can then be used to take out enemies. (Of course, the player can also be shot through the same gap.)

The system of updating only the minimum necessary number of pixels works well as long as there’s no need for objects to overlap. In the case of the shields, though, what happens when objects do overlap is fundamental to how they work. Whenever a shot hits something, it’s replaced by an explosion sprite. A few frames later, the explosion sprite is deleted from the screen. If the explosion sprite overlapped with a shield, that part of the shield is also deleted.

Wireframe 9 Space Invaders

Here’s a code snippet that shows Andrew’s Space Invaders-style disintegrating shields working in Python. To get it running on your system, you’ll need to install Pygame Zero — you can find full instructions here. And download the above code here.

The code to the right displays four shields, and then bombards them with a series of shots which explode on impact. I’m using sprites which have been scaled up by ten, to make it easier to see what’s going on.

We first create two empty lists — one to hold details of any shots on screen, as well as explosions. These will be displayed on the screen every frame. Each entry in the shots list will be a dictionary data structure containing three values: a position, the sprite to be displayed, and whether the shot is in ‘exploding’ mode — in which case it’s displayed in the same position for a few frames before being deleted.

The second list, to_delete, is for sprites which need to be deleted from the screen. For simplicity, I’m using separate copies of the shot and explosion sprites where the white pixels have been changed to black (the other pixels in these sprites are set as transparent).

The function create_random_shot is called every half-second. The combination of dividing the maximum value by ten, choosing a random whole number between zero and the maximum value, and then multiplying the resulting random number by ten, ensures that the chosen X coordinate is a multiple of ten.

Wireframe 9 Space Invaders Wireframe 9 Space Invaders

Andrew’s Space Invaders shields up and running in Pygame Zero.

In the draw function, we first check to see if it’s the first frame, as we only want to display the shields on that frame. The screen.blit method is used to display sprites, and Pygame Zero’s images object is used to specify which sprite should be displayed. We then display all sprites in the to_delete list, after which we reset it to being an empty list. Finally we display all sprites in the shots list.

Wireframe 9 Space Invaders

In the update function, we go through all sprites in the shots list, in reverse order. Going through the list backwards avoids problems that can occur when deleting items from a list inside a for loop. For each shot, we first check to see if it’s in ‘exploding’ mode. If so, its timer is reduced each frame — when it hits zero we add the shot to the to_delete list, then delete it from shots.

If the item is a normal shot rather than an explosion, we add its current position to to_delete, then update the shot’s position to move the sprite down the screen. We next check to see if the sprite has either gone off the bottom of the screen or collided with something. Pygame’s get_at method gives us the colour of a pixel at a given position. If a collision occurs, we switch the shot into ‘exploding’ mode — the explosion sprite will be displayed for five frames.

You can read the rest of the feature in Wireframe issue 9, available now in Tesco, WHSmith, and all good independent UK newsagents.

Or you can buy Wireframe directly from us – worldwide delivery is available. And if you’d like to own a handy digital version of the magazine, you can also download a free PDF.

Make sure to follow Wireframe on Twitter and Facebook for updates and exclusives, and for subscriptions, visit the Wireframe website to save 49% compared to newsstand pricing!

The post Coding Space Invaders’ disintegrating shields | Wireframe #9 appeared first on Raspberry Pi.

So how to do CW on a homebrew SSB rig?

via Dangerous Prototypes

IMG_4379

Pete Juliano, N6QW, has written an article on how to do CW on a homebrew SSB rig:

The Answer is Not a Flippant: Carefully!
Author’s note: A friend in VK4 land made an inquiry about CW operation. I find that 99.99% of my operating time is SSB. But others spend a greater time on the air using CW so why not share some info and data that I have stashed on my computer where a SSB rig can be made to work CW. This also open the possibility of filter switching for a more narrow pass band. With Arduino anything may be possible.

More details on Pete Juliano’s (N6QW) blog.

IoT LED Dimmer

via Dangerous Prototypes

IOT-Dimmer

Sasa Karanovic shared a how-to on making a IoT LED dimmer:

Making a IoT LED dimmer that you can control via your PC, phone, tablet or any other device connected to the network is super simple, and I’m going to show you how.
I’m sharing my three channel LED dimmer that you can use to dim single RGB LED strip or dim three separate LED channels. I want to be able to control lights above my desk and also mix warm white and cool white strip to give me more flexibility over lighting while I’m working, taking pictures or watching movies.

See the full post on Sasa Karanovic’s blog.

How to build your Energy Load manager

via Dangerous Prototypes

featured-4

A detailed instructions of how to build an Energy Load manager from Open Electronics:

When the instantaneous power consumption exceeds the set values, it selectively disconnects the users, in order to prevent the electric meter to cut the power to disconnect.
The management of the electricity users at home, intended as the possibility to define the operating priorities and to momentarily disconnect the ones that may be “sacrificed”, is something that has become important since the coming of the electronic meters. With respect to the traditional ones, such meters are in fact a bit less tolerant towards the overloads, and they could suddenly leave us without power. Given that nowadays the electric meter is almost always outside and that in order to rearm it we should get out of the house; not to mention that the disconnection will probably turn off the computer that is sending files via the Internet, or that a user might not be able to shut down. In order to prevent such a situation, we created the load manager: in the previous installment, we described its hardware. It is now the moment to deal with the software governing it, and with the management of its functioning via the user interface.

Project info at open-electronics.org.

Build a Multisensor Shield for ESP8266

via Dangerous Prototypes

Build-ESP8266-WeMos-D1-Mini-Multisensor-Shield

Rui Santos has a great write-up on building a Multisensor Shield for ESP8266, that is available on GitHub:

In this project you’ll discover how to design and create a Multisensor Shield for the ESP8266 Wemos D1 Mini board. The shield has temperature sensor (DS18B20), a PIR motion sensor, an LDR, and a terminal to connect a relay module. We’ll start by preparing all the hardware and then program it.

See the full post on Random Nerd Tutorials blog.