Category Archives: Raspberry Pi

Raspberry Pi controlling a LED cube with Python

The above LED cube [VoxCube] is being controlled via a Raspberry Pi, using python and the official Raspberry Pi display.

Buttons were setup using the Kivy. Kivy is a Python library which makes creating buttons and events with a touchscreen very easy.

Here is a very good guide on how to get Kivy setup on a Raspberry Pi.
Continue reading Raspberry Pi controlling a LED cube with Python

New Kickstarter – VoxCube – 8x8x8 RGB LED Cube for the Raspberry Pi

We have been busy over the last 6 months creating something special!
We have always liked the idea of LED cubes, however there was no easy way to drive these LED cubes with a Raspberry Pi…. until now.

 


VoxCube is an 8x8x8 RGB LED Cube which has been specifically designed for the Raspberry Pi, however it is also compatible with other microcontrollers. E.g. Arduino

Cubes can also be chained together, the image below is four VoxCubes being controller via a Raspberry Pi.

Four VoxCube Raspberry Pi LED

 

Head over to the Kickstarter page for more details.

Kickstarter LED cube

 

 

Super low cost VGA output for the Pi Zero • Hackaday.io

Here is a great post by mincepi which shows how to enable VGA output on a Pi Zero for less than $5

The vga666 by Gert is already a low cost VGA output option for the Pi. But we can do better with the Zero! We’ll use 16 bit output instead of 18 bit: this frees up the SPI and I2C ports with little loss in quality. The resistors can be soldered between the Zero and the adapter, making the PCB smaller and eliminating a connector. I’ve determined that 5% resistors are good enough: no need for higher cost 1% units. By not using the middle row of pins in the HD15 connector, we can straddle-mount it on the PCB edge. Finally, the connector can be male, so the Zero will connect to the monitor ChromeCast style: no VGA cable needed. (This connector could even be scrounged from an old VGA monitor cable for free!) If you order the boards from OSHPark, it will cost $4.95 for three copies. Enough resistors and connectors to build three will cost $5.92 from Digi-Key. That works out to $10.87 to build three, or $3.62 each!

 

Source: Super low cost VGA output for the Pi Zero • Hackaday.io

 

BerryIMU Raspberry Pi Gyroscope Accelerometer

Add Colour to Text in Python

To make some of your text more readable, you can use ANSI escape codes to change the colour of the text output in your python program. A good use case for this is to to highlight errors.

The escape codes are entered right into the print statement.

print("\033[1;32;40m Bright Green  \n")

 

The above ANSI escape code will set the text colour to bright green. The format is;
\033[  Escape code, this is always the same
1 = Style, 1 for normal.
32 = Text colour, 32 for bright green.
40m = Background colour, 40 is for black.

 

This table shows some of the available formats;

Text color Code Text style Code Background color Code
Black 30 No effect 0 Black 40
Red 31 Bold 1 Red 41
Green 32 Underline 2 Green 42
Yellow 33 Negative1 3 Yellow 43
Blue 34 Negative2 5 Blue 44
Purple 35 Purple 45
Cyan 36 Cyan 46
White 37 White 47

 

 

BerryIMU Raspberry Pi Gyroscope Accelerometer

 

 

Here is the code used to create the coloured text in the title image;

print("\033[0;37;40m Normal text\n")
print("\033[2;37;40m Underlined text\033[0;37;40m \n")
print("\033[1;37;40m Bright Colour\033[0;37;40m \n")
print("\033[3;37;40m Negative Colour\033[0;37;40m \n")
print("\033[5;37;40m Negative Colour\033[0;37;40m\n")

print("\033[1;37;40m \033[2;37:40m TextColour BlackBackground          TextColour GreyBackground                WhiteText ColouredBackground\033[0;37;40m\n")
print("\033[1;30;40m Dark Gray      \033[0m 1;30;40m            \033[0;30;47m Black      \033[0m 0;30;47m               \033[0;37;41m Black      \033[0m 0;37;41m")
print("\033[1;31;40m Bright Red     \033[0m 1;31;40m            \033[0;31;47m Red        \033[0m 0;31;47m               \033[0;37;42m Black      \033[0m 0;37;42m")
print("\033[1;32;40m Bright Green   \033[0m 1;32;40m            \033[0;32;47m Green      \033[0m 0;32;47m               \033[0;37;43m Black      \033[0m 0;37;43m")
print("\033[1;33;40m Yellow         \033[0m 1;33;40m            \033[0;33;47m Brown      \033[0m 0;33;47m               \033[0;37;44m Black      \033[0m 0;37;44m")
print("\033[1;34;40m Bright Blue    \033[0m 1;34;40m            \033[0;34;47m Blue       \033[0m 0;34;47m               \033[0;37;45m Black      \033[0m 0;37;45m")
print("\033[1;35;40m Bright Magenta \033[0m 1;35;40m            \033[0;35;47m Magenta    \033[0m 0;35;47m               \033[0;37;46m Black      \033[0m 0;37;46m")
print("\033[1;36;40m Bright Cyan    \033[0m 1;36;40m            \033[0;36;47m Cyan       \033[0m 0;36;47m               \033[0;37;47m Black      \033[0m 0;37;47m")
print("\033[1;37;40m White          \033[0m 1;37;40m            \033[0;37;40m Light Grey \033[0m 0;37;40m               \033[0;37;48m Black      \033[0m 0;37;48m")

\n")

Enable boot logging on the Raspberry Pi

When troubleshooting issues on a Raspberry Pi sometimes it is helpful to go back and look at the boot log, especially if you are running a headless (no monitor) Raspberry Pi.

Install bootlogd

 

pi@raspberrypi ~ $ sudo apt-get install bootlogd

 

You will be asked to restart services, select ‘Yes’.  And then reboot your Raspberry Pi

View Boot Log

From now on, if you wish to view the bootlog, you can use the command below to format it correctly;

pi@raspberrypi ~ $ sed 's/\^\[/\o33/g;s/\[1G\[/\[27G\[/' /var/log/boot

You will get the output as shown in the image at the top of this post.