logo
home 製造技術 製造設備
工業製造
産業用モノのインターネット | 工業材料 | 機器のメンテナンスと修理 | 産業プログラミング |
home  MfgRobots >> 工業製造 >  >> Manufacturing Technology >> 製造プロセス

Zerynth Lamp: NeoPixel LEDでスマートIoT間接照明制御

部品と用品

Zerynth Shield (マルチセンサーボード) ×1
Arduino Due または ST Nucleo F401RE または Particle Photon または UDOO Dual または Flip&Clip (Mikroelektronika) ×1
Adafruit NeoPixel LEDストリップ/リング ×1
Wi-Fiシールド (CC3000搭載) ※Particle Photon使用時は不要 (オンボードWi-Fi) ×1
ガラス製または3Dプリント製ランプシェード ×1

アプリとオンラインサービス

  • Zerynth Studio (マルチプラットフォーム/ブラウザベースPython開発環境、クラウド同期・ボード管理機能付き)
  • Zerynth App (スマートオブジェクト/IoTシステム用モバイルインターフェース、スマホがディスプレイ兼リモコンに)

このプロジェクトについて

低電力無線規格、低コスト・超小型LED・センサー・通信デバイスの普及により、スマート照明はIoTとホームオートメーションの触媒となっています。本チュートリアルでは、Zerynth AppからNeoPixel LEDストリップを制御する方法を紹介します。アプリにはカラーピッカーとプリセットアニメーション選択メニューが表示されます。

ステップ1: 必要な材料

  • Zerynth Studio: ダウンロード/インストール (OS問わず動作)
  • Zerynth App: ダウンロード
  • Zerynth Shield: 購入可能 - タッチ/赤外線/マイク/光/温度センサー搭載のマルチセンサーボード
  • 対応ボード: Arduino Due、ST Nucleo F401RE、Particle Photon、UDOO、Flip&Clipなど (Zerynthはマルチボード対応、対応リスト)
  • Wi-Fi接続: Particle Photon以外はWi-Fiシールド (Adafruit CC3000搭載等) 必要
  • NeoPixel LED: Adafruit製
  • ランプ本体: ガラス製または3Dプリント製、お好みで

ステップ2: 組み立て

  1. Wi-FiシールドとZerynth ShieldをArduino (または対応ボード) にピギーバック接続。Particle Photonの場合はZerynth Shieldの専用コネクタに直接装着
  2. NeoPixel LEDをZerynth Shieldの専用ポートに接続
  3. すべての基板とLEDをランプシェード内に収納

Zerynth Lamp: NeoPixel LEDでスマートIoT間接照明制御

ステップ3: プログラミング

Zerynth Studioでの開発手順:

  1. ボードを接続して「仮想化」 (解説記事)
  2. 新規プロジェクト作成 (解説記事) - main.py、animation.py、template.html、project.md の4ファイル作成
  3. 以下のコードをコピー
  4. ボードにアップロード (uplink) して完了!

起動後、プリセットネットワークに自動接続。Zerynth Appを開くとネットワーク上のZerynthオブジェクトを検索、「Zerynth Lamp」を選択で操作可能。カラーピッカーとアニメーションメニューで直感制御。

コードは豊富なコメント付きでシンプル。質問・提案は Zerynthコミュニティフォーラム へ。

ステップ4: IoTをもっと明るく!

Zerynth Shieldにはタッチ検知、赤外線LED、マイク、光センサー、温度センサーなどが搭載。このシンプルな例をベースに、好みの動作を開発可能。Zerynth Shieldでランプ機能を拡張しましょう!

— Luigi F. Cerfeda (@L_F_Cerfeda) - Zerynthチーム

コード

main.py (Python)


################################################################################
# Zerynth Lamp
# Created by Zerynth Team 2015 CC
# Authors: G. Baldi, D. Mazzei
################################################################################
import streams
from bcm43362 import bcm43362 as wifi_driver
from wireless import wifi
import animation
from toishield import toishield
from zerynthapp import zerynthapp

streams.serial()

# Wi-Fi接続
try:
    wifi_driver.auto_init()
    print("Establishing Link...")
    wifi.link("SSID", wifi.WIFI_WPA2, "password")
    print("Ok!")
except Exception as e:
    print(e)

# template.htmlをボードフラッシュに保存
new_resource("template.html")

#### ZerynthApp Setup
# JavaScript → Python 呼び出し関数
def change_color(r, g, b):
    animation.setup_color(r, g, b)

def change_animation(n):
    animation.setup_anim(n)

def change_speed(n):
    animation.setup_anim_speed(n)

# ZerynthApp設定: 名前、説明、テンプレートURL
vp = zerynthapp.ZerynthApp("Zerynth Lamp", "Try me!", "resource://template.html")
vp.on("change_color", change_color)
vp.on("change_animation", change_animation)
vp.on("change_speed", change_speed)
vp.run()

# バックグラウンドでLED制御継続
animation.start(D6, 24)

template.html (HTML/JavaScript)




  
  
  
  
  


  

Zerynth Lamp

Powered by Zerynth (www.zerynth.com)

animation.py (Python)


################################################################################
# Zerynth Lamp - Animation Functions
################################################################################
from neopixel import ledstrips as neo
import threading

lock = threading.Lock()
color = [0x54, 0x9a, 0x97]  # デフォルト色 (Zerynthカラー)
anim = 0
anim_speed = 50
leds = None
layer0 = layer1 = layer2 = None
npins = 0
stopped = False
stopcolor = [0xff, 0xff, 0xff]

# スムーズアニメーション用係数 (半周正弦波)
animation_coefficients = [
  0, 0.2588, 0.5, 0.7071, 0.8660, 0.9659,
  1, 0.9659, 0.8660, 0.7071, 0.5, 0.2588
]

rainbow = [
  (0xff,0x00,0x00), (0xff,0x7f,0x00), (0xff,0xff,0x00),
  (0x00,0xff,0x00), (0x00,0x00,0xff), (0x4b,0x00,0x82), (0x8f,0x00,0xff)
]

def setup_anim(n):
    global layer0,layer1,layer2,anim
    lock.acquire()
    leds.clear(); layer2.clear(); layer0.clear(); layer1.clear()
    n = n % 4
    if n == 0:  # Little Snakes
        layer0[0]=layer0[1]=layer0[2]=(100,0,0)
        layer1[0]=layer1[1]=layer1[2]=(0,100,0)
    elif n == 1:  # Spinner
        for x in range(npins//2):
            layer0[x]=(100//(2*x+1),0,0)
            layer1[npins-x-1]=(0,100//(2*x+1),0)
        layer2.clear()
    elif n == 2:  # Rainbow
        layer1.clear()
        pstep = 0
        for x in range(npins):
            step = x*len(rainbow)/npins
            rx = (rainbow[int(step)][0]+rainbow[int(pstep)][0])//4
            gx = (rainbow[int(step)][1]+rainbow[int(pstep)][1])//4
            bx = (rainbow[int(step)][2]+rainbow[int(pstep)][2])//4
            layer0[x]=(rx,gx,bx)
            pstep = step
    elif n == 3:  # Pulse
        layer0.clear(); layer1.clear()
    anim = n
    lock.release()

def setup_anim_speed(n):
    global anim_speed
    anim_speed = n

def setup_color(r,g,b):
    global color
    color[0]=r; color[1]=g; color[2]=b

# バックグラウンドアニメーション (Pulse用)
def animate_background(delay):
    global color, stopped
    step = 0
    while True:
        if (anim==3 or anim==0) and not stopped:
            lock.acquire()
            layer2.setall(int(color[0]*animation_coefficients[step]/2),
                         int(color[1]*animation_coefficients[step]/2),
                         int(color[2]*animation_coefficients[step]/2))
            lock.release()
            step = (step + 1) % len(animation_coefficients)
        else:
            lock.acquire()
            layer2.clear(); layer2.setall(stopcolor[0],stopcolor[1],stopcolor[2])
            lock.release()
        sleep(delay+500-5*anim_speed)

# フォアグラウンドアニメーション (Snakes/Spinner/Rainbow)
def animate_foreground(delay):
    global stopped
    while True:
        if not stopped:
            lock.acquire()
            if anim == 0: layer0.lshift(); layer1.rshift()
            elif anim == 1: layer0.rshift(); layer1.rshift()
            elif anim == 2: layer0.rshift(); layer1.rshift()
            elif anim == 3: layer0.lshift(); layer1.lshift()
            lock.release()
        else:
            lock.acquire(); layer0.clear(); layer1.clear(); lock.release()
        sleep(delay+100-anim_speed)

def start(pin, numpins):
    global leds,layer0,layer1,layer2,npins
    npins = numpins
    leds = neo.LedStrip(pin, numpins)
    layer0 = neo.LedStrip(pin, numpins)
    layer1 = neo.LedStrip(pin, numpins)
    layer2 = neo.LedStrip(pin, numpins)
    setup_anim(0)
    setup_anim_speed(50)
    thread(animate_background, 500)
    thread(animate_foreground, 50)
    while True:
        leds.clear()
        lock.acquire()
        leds.merge(layer0); leds.merge(layer1)
        leds.merge(layer2, neo.first_color)  # 透明部分のみ背景合成
        lock.release()
        leds.on()
        sleep(50)

def stop(r,g,b):
    global stopped, stopcolor
    stopcolor[0]=r; stopcolor[1]=g; stopcolor[2]=b
    stopped = True

def resume():
    global stopped
    stopped = False
    setup_anim(anim)

回路図

Zerynth Lamp: NeoPixel LEDでスマートIoT間接照明制御

ポータブル温度監視ステーション: TMP36とLCDで高精度表示 Arduinoシフトレジスタで美しい光のシーケンスを作成

製造プロセス

  • 製造プロセス
  • 3Dプリント
  • 自動制御システム
  • 産業技術
    1. ガスランタン:進化、設計、現代製造
    2. レーザーポインター:設計、製造、安全性の概要
    3. 懐中電灯:発明から現代革新まで
    4. ハロゲンランプ:技術、歴史、そして未来——専門家の視点
    5. 万華鏡:ブレッサーの科学から現代デザインへ
    6. 信号機:工学、歴史、未来の革新
    7. 火からフィラメントへ:現代電球の進化と生産
    8. Raspberry PiとDS18B20でマルチセンサー温度・光監視システムを構築
    9. スマート信号機:IoTで実現する適応型街路灯
    10. デジタル光センサー:Windows 10 IoT Coreで周囲光に応じてLEDを制御
    11. 光速での電気信号伝播:186,000マイルの思考実験
    • フォトレジスタとLEDで作る環境光センサー – ステップバイステップガイド

      部品と用品 部品数量備考 Arduino UNO1アナログピン1つ、デジタルピン2つ以上、GND3つ以上あれば他のボードでも可 フォトレジスタ(光依存抵抗)1 LED(汎用)2異なる色2個 抵抗 1kΩ1フォトレジスタ用プルダウン 抵抗 100Ω2220Ωでも動作しますが、100Ωの方がLEDが明るくなります ジャンパーワイヤー(汎用)1 ブレッドボード(汎用)1 アプリとオンラインサービス Arduino IDE Arduino Web Editor このプロジェクトについて Arduinoを使い始めて少し経ち、そろそろゼロから自分でプロジェクトを設計する時だと感じました

    • VL6180Xとサーボモーターで作るArduino LIDARシステム

      必要な部品と材料 部品数量備考 Arduino UNO1制御用マイコン VL6180X ToF距離センサー (SparkFun等)1短距離用。長距離ならVL53L0X推奨 サーボモーター (SG90等)1センサー水平走査用 使用ソフトウェア・サービス Arduino IDE Processing (可視化用) プロジェクト概要 LiDAR (Light Detection and Ranging) の基礎 LiDARはレーザー光を照射し、反射光が戻るまでの時間(ToF: Time of Flight)または位相差から距離を測定する光学リモートセンシング技術です。ロボティク

    • スマートIoTペットフィーダー:モーション検知搭載の自動給餌システム

      必要な部品と材料 部品 数量 Arduino UNO 1 PIRモーションセンサー(汎用) 1 Espressif ESP8266 ESP-01 1 スピーカー:0.25W、8Ω 1 SparkFun サーボ - 汎用メタルギア(マイクロサイズ) 1 使用アプリとオンラインサービス circuito.io(マジックリンク:プロジェクト用コンポーネント選択済みページ) プロジェクト概要 これはcircuito.ioを使った私たちの最初のIoTプロジェクトです。コミュニティと共有し、circuito.ioを使えば基本的なIoTプロジェクトがいかに簡単に作

    • DIY LEDランプキット:省エネ・エコな照明を自作しよう

      DIY LEDランプキットは、自宅用でも電子工作学習でも最適なプロジェクトです。環境配慮型、省エネ、電気代削減で近年人気急上昇中。LEDランプ単体では点灯せず、回路が必要です。 キット製作は習得容易。本記事で回路機能の理解、はんだ付け手順、各種LEDライトキットの知識が得られます。 DIY LEDランプキット構成 必要工具 30Wはんだごて 0.8mmはんだ線 マルチメーター ピンセット ニッパー キット部品 10Ω R2 金属皮膜抵抗 ×1 200kΩ R3 金属皮膜抵抗 ×1 470kΩ R1 コンデンサ ×1 ※抵抗の誤記と思われる 1μF 400V C1 コンデンサ ×1 4

    言語

    • Windowsの知識
    • 古典芸術
    • 休暇旅行
    • 現代農学
    • 自動車技術
    • コンピューター
    • German
    • French
    • Spanish
    • Portuguese
    • Chinese
    • Indonesian
    • Japanese
    • Korean
    • Netherlands
    • Russian
    logo
    工業製造
    著作権© mfgrobots.com 全著作権所有