NightLight Hat Board For Raspberry Pi SKU: EP-0098: Difference between revisions
Line 103: | Line 103: | ||
| 0x18 || blue color || No.8 | | 0x18 || blue color || No.8 | ||
|} | |} | ||
==Example Demo== | |||
* Shell script | |||
samle script to light up all LED's individually in a loop.<br> | |||
<code> | |||
#!/bin/bash | |||
# lights up each LED individually in a loop. | |||
while true | |||
do | |||
for i in `seq 1 9` | |||
do | |||
for x in a b c d e f | |||
do | |||
i2cset -y 1 0x15 0x0$i 0x00 # turn off all LEDs. | |||
done | |||
done | |||
# lights up first line | |||
i2cset -y 1 0x15 0x01 0x55 # turn on No.1 led in half power. | |||
i2cset -y 1 0x15 0x04 0x55 # turn on No.2 led in half power. | |||
sleep 0.1 # delay for a while. | |||
i2cset -y 1 0x15 0x01 0xff # turn on No.1 led in full power. | |||
i2cset -y 1 0x15 0x04 0xff # turn on No.2 led in full power. | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x01 0x00 # turn off No.1 led | |||
i2cset -y 1 0x15 0x04 0x00 # turn off No.2 led | |||
# lights up second line | |||
i2cset -y 1 0x15 0x07 0x55 | |||
i2cset -y 1 0x15 0x0a 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x07 0xff | |||
i2cset -y 1 0x15 0x0a 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x07 0x00 | |||
i2cset -y 1 0x15 0x0a 0x00 | |||
i2cset -y 1 0x15 0x08 0x55 | |||
i2cset -y 1 0x15 0x0b 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x08 0xff | |||
i2cset -y 1 0x15 0x0b 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x08 0x00 | |||
i2cset -y 1 0x15 0x0b 0x00 | |||
i2cset -y 1 0x15 0x09 0x55 | |||
i2cset -y 1 0x15 0x0c 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x09 0xff | |||
i2cset -y 1 0x15 0x0c 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x09 0x00 | |||
i2cset -y 1 0x15 0x0c 0x00 | |||
i2cset -y 1 0x15 0x0d 0x55 | |||
i2cset -y 1 0x15 0x10 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x0d 0xff | |||
i2cset -y 1 0x15 0x10 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x0d 0x00 | |||
i2cset -y 1 0x15 0x10 0x00 | |||
i2cset -y 1 0x15 0x0e 0x55 | |||
i2cset -y 1 0x15 0x11 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x0e 0xff | |||
i2cset -y 1 0x15 0x11 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x0e 0x00 | |||
i2cset -y 1 0x15 0x11 0x00 | |||
i2cset -y 1 0x15 0x0f 0x55 | |||
i2cset -y 1 0x15 0x12 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x0f 0xff | |||
i2cset -y 1 0x15 0x12 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x0f 0x00 | |||
i2cset -y 1 0x15 0x12 0x00 | |||
i2cset -y 1 0x15 0x13 0x55 | |||
i2cset -y 1 0x15 0x16 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x13 0xff | |||
i2cset -y 1 0x15 0x16 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x13 0x00 | |||
i2cset -y 1 0x15 0x16 0x00 | |||
i2cset -y 1 0x15 0x14 0x55 | |||
i2cset -y 1 0x15 0x17 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x14 0xff | |||
i2cset -y 1 0x15 0x17 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x14 0x00 | |||
i2cset -y 1 0x15 0x17 0x00 | |||
i2cset -y 1 0x15 0x15 0x55 | |||
i2cset -y 1 0x15 0x18 0x55 | |||
sleep 0.1 | |||
i2cset -y 1 0x15 0x15 0xff | |||
i2cset -y 1 0x15 0x18 0xff | |||
sleep 0.5 | |||
i2cset -y 1 0x15 0x15 0x00 | |||
i2cset -y 1 0x15 0x18 0x00 | |||
sleep 0.5 | |||
done | |||
</code><br> |
Revision as of 14:56, 26 November 2018
NightLight Hat Board For Raspberry Pi
Description
NightLight Hat Board For Raspberry Pi is a Hat Board which have 8 WS2812 RGB LED lights.
And this Hat Board will communicate with Raspberry Pi via I2C protocol.
You can control each LED's color individually by command.
At the same time, you can also adjust the brightness of each LED by command.
The light board is connected to the GPIO pin by HAT.
You can stack multiple identical boards in a layered manner, which can make your lighting more layered.
It is recommended not to exceed four layers at most. Otherwise, the power supply may be insufficient.
Because all the lights need to be powered from the GPIO pin of the Raspberry Pi.
The feature of the HAT board is that you don't have to worry about messy cables.
If you only use one layer of light board, you can engrave your favorite pattern on an acrylic board with a laser engraving machine,
and then insert it vertically into the random acrylic bracket,
so that by controlling the light, you can make different The acrylic art board presents a different brilliance, turning your light board into a work of art.
Features
- Easy to setup
- 8xRGB WS2812 Lights
- Extend the GPIO Pins
- Can stack 4 pieces
- Can Stack with other Stack board such as Relay module
- Individual control of each Light
- With beautiful acrylic light guide,Two factory-made patterns, two of them are blank for you DIY
- Plug and Play
- One command control
Gallery
Package Includes
- 1 x NightLight Hat Board For Raspberry Pi
- 4 x Screws & Nuts
- 5 x Acrylic Pattern Design
How to use it
- Turn on the I2C interface
Open a terminal and Run sudo raspi-config
Use the down arrow to select 5 Interfacing Options.
Arrow down to P5 I2C .
Select yes when it asks you to enable I2C.
Also select yes if it asks about automatically loading the kernel module.
Use the right arrow to select the <Finish> button.
Select yes when it asks to reboot.
- Detect the register of the chip on board
i2cdetect -y 1
you will see this result:
- Lights up one light
i2cset -y 1 0x15 0x01 0xff
This register "0x15" means the MCU address of this board. "0x01" means the first light's first color of the board, every light has a register address, and you can follow this chart, "0xff" means give the light 100% power and "0x00" will kill the light, you can put the value from "0x00" to "0xff" to make a dim light.
Register Number | Color | Light number |
---|---|---|
0x01 | red color | No.1 |
0x02 | green color | No.1 |
0x03 | blue color | No.1 |
0x04 | red color | No.2 |
0x05 | green color | No.2 |
0x06 | blue color | No.2 |
0x07 | red color | No.3 |
0x08 | green color | No.3 |
0x09 | blue color | No.3 |
0x0a | red color | No.4 |
0x0b | green color | No.4 |
0x0c | blue color | No.4 |
0x0d | red color | No.5 |
0x0e | green color | No.5 |
0x0f | blue color | No.5 |
0x10 | red color | No.6 |
0x11 | green color | No.6 |
0x12 | blue color | No.6 |
0x13 | red color | No.7 |
0x14 | green color | No.7 |
0x15 | blue color | No.7 |
0x16 | red color | No.8 |
0x17 | green color | No.8 |
0x18 | blue color | No.8 |
Example Demo
- Shell script
samle script to light up all LED's individually in a loop.
- !/bin/bash
- lights up each LED individually in a loop.
while true
do
for i in `seq 1 9`
do
for x in a b c d e f
do
i2cset -y 1 0x15 0x0$i 0x00 # turn off all LEDs.
done
done
# lights up first line
i2cset -y 1 0x15 0x01 0x55 # turn on No.1 led in half power.
i2cset -y 1 0x15 0x04 0x55 # turn on No.2 led in half power.
sleep 0.1 # delay for a while.
i2cset -y 1 0x15 0x01 0xff # turn on No.1 led in full power.
i2cset -y 1 0x15 0x04 0xff # turn on No.2 led in full power.
sleep 0.5
i2cset -y 1 0x15 0x01 0x00 # turn off No.1 led
i2cset -y 1 0x15 0x04 0x00 # turn off No.2 led
# lights up second line
i2cset -y 1 0x15 0x07 0x55
i2cset -y 1 0x15 0x0a 0x55
sleep 0.1
i2cset -y 1 0x15 0x07 0xff
i2cset -y 1 0x15 0x0a 0xff
sleep 0.5
i2cset -y 1 0x15 0x07 0x00
i2cset -y 1 0x15 0x0a 0x00
i2cset -y 1 0x15 0x08 0x55
i2cset -y 1 0x15 0x0b 0x55
sleep 0.1
i2cset -y 1 0x15 0x08 0xff
i2cset -y 1 0x15 0x0b 0xff
sleep 0.5
i2cset -y 1 0x15 0x08 0x00
i2cset -y 1 0x15 0x0b 0x00
i2cset -y 1 0x15 0x09 0x55
i2cset -y 1 0x15 0x0c 0x55
sleep 0.1
i2cset -y 1 0x15 0x09 0xff
i2cset -y 1 0x15 0x0c 0xff
sleep 0.5
i2cset -y 1 0x15 0x09 0x00
i2cset -y 1 0x15 0x0c 0x00
i2cset -y 1 0x15 0x0d 0x55
i2cset -y 1 0x15 0x10 0x55
sleep 0.1
i2cset -y 1 0x15 0x0d 0xff
i2cset -y 1 0x15 0x10 0xff
sleep 0.5
i2cset -y 1 0x15 0x0d 0x00
i2cset -y 1 0x15 0x10 0x00
i2cset -y 1 0x15 0x0e 0x55
i2cset -y 1 0x15 0x11 0x55
sleep 0.1
i2cset -y 1 0x15 0x0e 0xff
i2cset -y 1 0x15 0x11 0xff
sleep 0.5
i2cset -y 1 0x15 0x0e 0x00
i2cset -y 1 0x15 0x11 0x00
i2cset -y 1 0x15 0x0f 0x55
i2cset -y 1 0x15 0x12 0x55
sleep 0.1
i2cset -y 1 0x15 0x0f 0xff
i2cset -y 1 0x15 0x12 0xff
sleep 0.5
i2cset -y 1 0x15 0x0f 0x00
i2cset -y 1 0x15 0x12 0x00
i2cset -y 1 0x15 0x13 0x55
i2cset -y 1 0x15 0x16 0x55
sleep 0.1
i2cset -y 1 0x15 0x13 0xff
i2cset -y 1 0x15 0x16 0xff
sleep 0.5
i2cset -y 1 0x15 0x13 0x00
i2cset -y 1 0x15 0x16 0x00
i2cset -y 1 0x15 0x14 0x55
i2cset -y 1 0x15 0x17 0x55
sleep 0.1
i2cset -y 1 0x15 0x14 0xff
i2cset -y 1 0x15 0x17 0xff
sleep 0.5
i2cset -y 1 0x15 0x14 0x00
i2cset -y 1 0x15 0x17 0x00
i2cset -y 1 0x15 0x15 0x55
i2cset -y 1 0x15 0x18 0x55
sleep 0.1
i2cset -y 1 0x15 0x15 0xff
i2cset -y 1 0x15 0x18 0xff
sleep 0.5
i2cset -y 1 0x15 0x15 0x00
i2cset -y 1 0x15 0x18 0x00
sleep 0.5
done