Code Monkey home page Code Monkey logo

pi-rgb's Introduction

Control an RGB LED with Raspberry Pi GPIO

Overview

Use wiringPi to control a common-anode RGB LED from the GPIO pins.

git clone git://git.drogon.net/wiringPi cd wiringPi ./build

Each color is actually switched by an NPN transistor so that you can drive the LED with +5v and more current than the GPIO pins can handle. Use a resource like http://www.kpsec.freeuk.com/trancirc.htm#ic to calculate the resistor value.

wiringPi software PWM

Only one GPIO pin supports hardware PWM, so we get to use this sweet software PWM library.

Setting the color

rgb.c will run all the time. Its job is to manage the GPIO pins based on the contents of a command structure that's set using mmap() for IPC.

To set the command (color and mode), see write_rgbcmd.c. It uses mmap() to choose the mode (on, off, blink, rainbow, and random) and the color for the on/blink modes.

CGI

We want to have a simple way to set the mode and color:

http://pi/rgbcmd/on/ff0012
http://pi/rgbcmd/blink/ff0000
http://pi/rgbcmd/off
http://pi/rgbcmd/rainbow
http://pi/rgbcmd/random

Usage

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This work is placed into the public domain.

pi-rgb's People

Contributors

jasonluther avatar

Watchers

 avatar  avatar

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.