Coder Social home page Coder Social logo

pi-ws2812's Introduction

Pi WS2812 LED Driver

A Java library to drive the popular WS2812 RGB LED from a Raspberry Pi. E.g. the unicorn-hat is a 8x8 array of those WS2812 RGB LEDs (https://shop.pimoroni.com/products/unicorn-hat)

This is a simple wrapper around Pimoroni's C library using JNA to relay the calls. The original C library is here:

https://github.com/pimoroni/unicorn-hat

For the moment this was just tested with Raspberry Pi B+ and not Raspberry Pi2. The enclosed c library is compiled with the GPIO memory location of model 1, so this most likely won't work with model 2 yet.

how to use?

First you need to clone and compile the library using Maven and then you can use the library in your maven projects like this:

<dependency>
    <groupId>de.pi3g.pi</groupId>
    <artifactId>pi-ws2812</artifactId>
    <version>1.0-SNAPSHOT</version>
</dependency>

The hardware needs to be connected to GPIO port #18 which has hardware PWM (which is needed here as the WS2812 has singal lengths of about 1.25us)

Then you can use the library like this:

WS2812.get().init(64); //init a chain of 64 LEDs
WS2812.get().clear();    
WS2812.get().setPixelColor(0, Color.RED); //sets the color of the fist LED to red
WS2812.get().show();

Note that you always need to call show() after you changed the color of any LED to publish the changes to the hardware.

how to build?

The entire project is build with maven. Just clone the master branch, open the directory in NetBeans and hit run. Or if you prefer the command line:

mvn install

should build everything correctly.

pi-ws2812's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.