My Beautiful Night Light With Raspberry Pi

About: I am a linux fan, a maker, a boy who like make thing and have fun with my friends.

Recently, I found that I fall in love with the beautiful light on raspberry pi.

I am jacky~, and i love make things on raspberry pi and recently i found that there are a series product for raspberry pi is very cool~

It based on I2C protocol communication, and it so easy to use.

The following pictures are the four products: 1. Docker Pi night light board ( based on ws2812 and communicate with raspberry pi via I2C protocol)

2. Docker Pi 4 channel Relay board ( based on relay module and communicate with raspberry pi via I2C protocol and can be stacked)

3. Docker Pi Power board with Fan ( this is all the same but it can provide 5V / 4A power supply, make sure the pi work properly while statcked)

4. Docker Pi IoT-Node(A) module ( It contains GPS, GSM(GPRS) and Lora module onboard, and still communicate with you pi via I2C protocol)

PS: It's all compatiable with Rasbperry Pi 4B !!!

https://www.amazon.com/GeeekPi-Night-Light-WS2812-...

https://www.amazon.co.uk/GeeekPi-Raspberry-Expansi...

Step 1:

1. Configuring I2C(Raspberry Pi)

Run sudo raspi-config and follow the prompts to install i2c support for the ARM core and linux kernel Go to Interfacing Options > then I2C > Enable > Done

2. Direct control without programming(Raspberry Pi)

The following script demonstrates turn on and turn off each LED.

#!/bin/bash

for i in $(seq 1 24)

do

i2cset -y 1 0x15 $i 0xFF # turn on the led

sleep 0.5

i2cset -y 1 0x15 $i 0x00 # turn of the led

sleep 0.5

done

3 .Program in Language C(Raspberry Pi)

Create source code and name it "led.c"

#include <stdio.h>

#include <wiringPi.h>

#include <wiringPiI2C.h>

#define BUTTON_REG_ADDR 0x19

int main()

{

int fd;

int is_press = 1;

int is_draw = 0;

int i = 0;

fd = wiringPiI2CSetup(0x15);

for(i = 1;i<25;i++)

{

wiringPiI2CWriteReg8(fd,i,0x00);

}


for(;;)

{

if (wiringPiI2CReadReg8(fd, BUTTON_REG_ADDR) == 0x01 )

{

is_press++;

is_draw = 1;

wiringPiI2CWriteReg8(fd,BUTTON_REG_ADDR, 0x0);

}

if(is_press && is_draw)

{

is_draw = 0;

for(i = 1;i<25;i++)

{

if(is_press > 3)

is_press = 1;

if(((i + is_press) % 3) == 0)

{

wiringPiI2CWriteReg8(fd,i,0xff);

}else{

wiringPiI2CWriteReg8(fd,i,0x00);

}

delay(100);

}

wiringPiI2CWriteReg8(fd,BUTTON_REG_ADDR, 0x0);

}

}

}

* Compile!

gcc led.c -lwiringPi -o led

Exec It!

./led

* Program in Language Python(Raspberry Pi)

The following code is recommended to be executed using Python 3 and install the smbus library:

import time as t import smbus

DEVICE_BUS = 1

DEVICE_ADDR = 0x15

bus = smbus.SMBus(DEVICE_BUS)

while True:

try:

for i in range(1,25):

bus.write_byte_data(DEVICE_ADDR, i, 0xFF)

t.sleep(0.2)

bus.write_byte_data(DEVICE_ADDR, i, 0x00)

t.sleep(0.2)

except KeyboardInterrupt as e:

print("Quit the Loop")

Step 2: Step 3. You Will See...

It's shining and blinking.

have fun~

Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Paint Challenge

      Paint Challenge
    • Beauty Tips Contest

      Beauty Tips Contest

    Discussions