logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Raspberry Pi

Raspberry Pi WebIOPi IOT – Full-Color LED Christmas Decoration

Device Plus Editorial Team
Published by Device Plus Editorial Team at December 16, 2017
Categories
  • Raspberry Pi
Tags
  • christmas
  • IoT
  • led
  • raspberry pi
  • WebIOPi

Create Python file

Since the operation of setting the value is done on the HTML side, Python side only needs to describe initial and termination processing.

/home/pi/webiopi_sample/python/script.py

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import webiopi
GPIO = webiopi.GPIO
RED   = 22
GREEN = 17
BLUE  = 27
def setup():
    # Set GPIO to PWM
    GPIO.setFunction(RED  , GPIO.PWM)
    GPIO.setFunction(GREEN, GPIO.PWM)
    GPIO.setFunction(BLUE , GPIO.PWM)
def destroy():
   # Light off
    GPIO.pwmWrite(RED  , 0)
    GPIO.pwmWrite(GREEN, 0)
    GPIO.pwmWrite(BLUE , 0)

Since PWM is used this time, specify “GPIO.PWM” as the second argument of the setFunction in lines 10 to 12. When “GPIO.OUT” is specified, the pulse signal is not recognized, and every time you move the slide bar it will make a flashing flash for a sec.

Although the processing to turn off the LED at the end of the program is described, the “pwmWrite” function is used.

PwmWrite (Channel, Value)

Write An Integer Value To The Given PWM Channel.

REST API: POST / Devices / Name / Pwm / Channel / Integer / Value

Name (Str): Device Name From Configuration File

Channel (Int): Analog Channel Number

value (int): integer value to output from 0 to pwmMaximum

In the first argument, specify the GPIO pin number and the value you want to set for the second argument. When the value is set to 0, it becomes OFF state and the LED is turned off.

Let’s run it!

Run command

1
sudo /etc/init.d/webiopi start

 

We tried to adjust the intensity of color development by moving the slide bar as shown in the video above. With red, green and blue monochrome, you can adjust the brightness like a gradation. In addition, by overlapping them, it became possible to express additive colors. Setting a very small value makes the lighting unstable with shimmer, so some degree of brightness is necessary.

led christmas decoration

Figure 7

It’s very convenient since Wi-Fi and WebIOPi‘s automatic startup settings can be used immediately just by turning on the power.

 

Christmas Decoration!

led christmas decoration

Figure 8

Installation is super easy, just insert the jumper wire directly into the LED pin as shown in the picture above. Sometimes they the wires come off, so it may be better solder them in.

led christmas decoration

Figure 9

I tried to put the LED inside a bell-shaped ornament. It looks pretty cool, doesn’t it?

Raspberry Pi’s GPIO alone was able to light up 2 full-color LEDs. If you want to connect more than one, it can be done using parts like a shift register.

Christmas is fast approaching! Why not get in the holiday mood with these cute led Christmas decorations? You can be even more creative, too! Try putting it in a transparent ornament or a candle. You can create handmade lighting using lots of LEDs for Christmas decorations!

 

1 2
Device Plus Editorial Team
Device Plus Editorial Team
Device Plus is for everyone who loves electronics and mechatronics.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • Let’s Make Arduino LED Holiday Lighting using Proximity SensorLet’s Make Arduino LED Holiday Lighting using Proximity Sensor
  • Raspberry Pi WebIOPi IOT Part 2 – Making a flashing LED buttonRaspberry Pi WebIOPi IOT Part 2 – Making a flashing LED button
  • Raspberry Pi WebIOPi IOT Part 3 – Programming Basics (Input/Output)Raspberry Pi WebIOPi IOT Part 3 – Programming Basics (Input/Output)
  • How to Add Siri Control to Your Raspberry Pi ProjectHow to Add Siri Control to Your Raspberry Pi Project
  • The Sense HAT Add-On Board For Raspberry Pi – Operating The LED DisplayThe Sense HAT Add-On Board For Raspberry Pi – Operating The LED Display
  • Make an LED Arduino Christmas Tree with ROHM Sensor KitMake an LED Arduino Christmas Tree with ROHM Sensor Kit
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2022. Device Plus - Powered by ROHM
© 2022 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort