Skip to content

sparkrew/led-control

Repository files navigation

LED Control for Raspberry Pi

JavaScript library for controlling DMX512 LED tubes via T-790K controller on Raspberry Pi.

Hardware Setup

  • LED Tube: DMX512 LED Tube Lights 24V, 360 Degree Lighting

    • 24 pixels per meter
    • DC24V power supply
    • DMX512 protocol
  • Controller: T-790K 8 Ports Digital LED Controller

    • Supports DMX512 and Art-Net protocols
    • TCP/IP network communication
    • 8 output ports
  • Power Supply: Mean Well LRS-350-24

    • DC24V output
    • 350W, 14.6A

Installation

Quick Setup (5 minutes)

See QUICK_START.md for fastest setup path.

Complete Setup

See INTEGRATION_GUIDE.md for detailed step-by-step instructions.

Basic Installation

  1. Install Node.js on your Raspberry Pi:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
  1. Navigate to the project directory:
cd led-control
  1. Install dependencies:
npm install

Configuration

Before running the code, you need to configure the controller IP address:

  1. Connect the T-790K controller to your network
  2. Find the controller's IP address (check your router's DHCP client list or use the controller's LCD screen)
  3. Update the host parameter in your scripts to match the controller's IP address

Example:

const leds = new LEDController({
  protocol: 'artnet',
  host: '192.168.1.100', // Your controller's IP address
  pixelsPerMeter: 24,
  tubeLength: 1 // Length in meters
});

Usage

Basic Usage

const LEDController = require('./index');

const leds = new LEDController({
  protocol: 'artnet',
  host: '192.168.1.100',
  pixelsPerMeter: 24,
  tubeLength: 1
});

// Set all LEDs to red
leds.setAll(255, 0, 0);
leds.update();

// Set a single pixel
leds.setPixel(0, 0, 255, 0); // Pixel 0 to green
leds.update();

// Clear all LEDs
leds.clear();

Running Examples

  1. Simple Test - Basic color tests:
npm test
# or
node examples/simple-test.js
  1. Rainbow Effect - Smooth rainbow animation:
node examples/rainbow-effect.js
  1. Chase Effect - Chasing light effect:
node examples/chase-effect.js

API Reference

LEDController(options)

Creates a new LED controller instance.

Options:

  • protocol (string): 'artnet' or 'dmx' (default: 'artnet')
  • host (string): Controller IP address (default: '192.168.1.100')
  • universe (number): DMX universe number (default: 1)
  • pixelsPerMeter (number): Number of pixels per meter (default: 24)
  • tubeLength (number): Length of LED tube in meters (default: 1)

Methods

setPixel(pixelIndex, r, g, b)

Set a single pixel color.

  • pixelIndex: Pixel index (0 to totalPixels-1)
  • r, g, b: Red, green, blue values (0-255)

setAll(r, g, b)

Set all pixels to the same color.

clear()

Clear all LEDs (set to black).

update()

Update the LED strip with current buffer values.

rainbow(offset)

Create a rainbow effect.

  • offset: Animation offset (0-255)

chase(position, width, r, g, b)

Create a chasing light effect.

  • position: Position of the chase
  • width: Width of the chase
  • r, g, b: Color values

close()

Cleanup and close connections.

Controller Setup

  1. Connect the LED tube to one of the controller's 8 output ports
  2. Connect the controller to your network via Ethernet
  3. Power on the controller and note its IP address
  4. Configure the controller for Art-Net or DMX512 mode (check controller manual)
  5. Set the DMX address if using DMX512 mode

Troubleshooting

  1. LEDs not responding:

    • Check controller IP address is correct
    • Verify network connection
    • Check controller is powered on
    • Verify LED tube is connected to controller
  2. Wrong colors:

    • Check RGB channel order (may need to adjust in code)
    • Verify DMX address settings
  3. Connection issues:

    • Ensure Raspberry Pi and controller are on the same network
    • Check firewall settings
    • Verify Art-Net/DMX512 protocol settings on controller

Notes

  • The controller supports both Art-Net and DMX512 protocols
  • Art-Net is recommended for network-based control
  • Each pixel uses 3 DMX channels (RGB)
  • Total channels = pixels × 3
  • For a 1-meter tube with 24 pixels/meter: 24 × 3 = 72 channels

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published