Raspberry Pi – Heart beat – 8×8 LED display with I2C BackPack from AdaFruit
This is based on the AdaFruit 8×8 Bicolor LED display with I2C BackPack. It’s connected to a Raspberry Pi 2, although it’s only very simple and could be connected to any model Raspberry Pi.
After soldering the parts together (checking that the display is the right way round – with the writing near the round marker) then connect to +5v (or if using other I2C may need to use 3V3) Gnd and ports 3 and 5 for the I2C connection.
Enable I2C through the raspi-config interface
Install smbus python package
sudo apt-get install smbus
Get the AdaFruit source code:
git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
I then put together the following code (which is only a quick hack):
#!/usr/bin/python
import time
import datetime
from Adafruit_8x8 import ColorEightByEight
grid = ColorEightByEight(address=0x70)
# This is a bicolour LED - setting the pixel to 0 is off, 2 is red, 3 is yellow.
red = 2
heart1=[0b00000000, 0b01100110, 0b10011001, 0b10000001, 0b01000010, 0b00100100, 0b00011000, 0b00000000]
heart2=[0b00000000, 0b01100110, 0b11111111, 0b11111111, 0b01111110, 0b00111100, 0b00011000, 0b00000000]
while(True):
for y in range(0, 8):
position = 128
for x in range(0, 8):
value = position & heart1[y]
if (value > 0):
value = red
grid.setPixel(x, y, value )
position = position >> 1
time.sleep(0.5)
for y in range(0, 8):
position = 128
for x in range(0, 8):
value = position & heart2[y]
if (value > 0):
value = red
grid.setPixel(x, y, value )
position = position >> 1
time.sleep(1)