GithubHelp home page GithubHelp logo

nicholasdollick / squid Goto Github PK

View Code? Open in Web Editor NEW

This project forked from simonmonk/squid

0.0 0.0 0.0 12 KB

Python Library for the Raspbery Squid RGB LED

License: MIT License

Python 100.00%

squid's Introduction

Squid

The Raspberry Squid is an RGB LED with built-in resistors and header lead sockets that can fit directly onto GPIO pins of a Raspberry Pi.

The Squid has its own library to make it super easy to mix colors on the RGB LED. After the library documentation that follows, you will find instructions on how to create your own Squid. Please feel free to make a squid for your own use, but please don't make them to resell.

If you don't want to make your own Squid, you can buy a ready made Raspberry Squid from http://www.monkmakes.com and you will also find it for same on Amazon.

An RGB LED Python Library.

Squid is a Python library to drive the Raspberry Squid RGB LED. Or in fact any common cathode RGB LED. The library also includes code for switch debouncing. Something that you may find useful if you have the Raspberry Squid's companion the Raspberry Button.

The Raspberry Squid is an RGB LED with built-in series resistors and sockets on the end of color-coded flying leads that will plug directly onto the GPIO header of a Raspberry Pi.

Raspberry Squid

The Raspberry Button follows the same concept, but has a push switch with protection resistor built into the leads.

Raspberry Squid

Installation

To install the library on your Raspberry Pi, enter the following commands in LX Terminal.

For Python 2 use:

$ git clone https://github.com/simonmonk/squid.git
$ cd squid
$ sudo python setup.py install

For Python 3 use:

$ git clone https://github.com/simonmonk/squid.git
$ cd squid
$ sudo python3 setup.py install

Connect the RGB LED

Plug in a Squid or connect up an RGB LED as follows:

  • Black, Common cathode of the LED to GND (the one between GPIO 18 and 23 is most convenient)
  • Red squid lead to GPIO18
  • Green squid lead to GPIO23
  • Blue squid lead to GPIO24

Try the Test Programs

There are two test programs, one (test.py) that simply turns the LED red, green, blue, white and then bright white. The other test program (gui.py) opens a TkInter window with three sliders to control the red, green and blue chanels of the LED.

First change to the examples directory using the command:

$ cd examples

To run test enter the following command:

$ sudo python test.py

To run gui.py enter the following command:

$ sudo python gui.py

This will open up the window below. Dragging the sliders about will allow you to mix any color. Note that this esample program requires a graphical interface so you cannot run it from SSH.

GUI Example

API Documentation

You can probably find all you need to know by looking at the source code for the examples.

Importing the library

from squid import *

Creating an Instance

rgb = Squid(18, 23, 24)

The three parameters are the pins connected to the red, green and blue LEDs.

set_color

rgb.set_color(RED)

The color can be one of the following constants: WHITE, OFF, RED, GREEN, BLUE, YELLOW, PURPLE and CYAN.

You can also just provide an array containing R, G and B values each between 0 and 100, like this:

rgb.set_color([100, 50, 10])

An optional second argument allows you specify the brightness of the color. The value of 100 is equivalent to one of the LEDs only being on at full brightness, thus if you make your R, G and B values add up to 100, then you can reasonably set the brightness value between 0 and 300.

rgb.set_color(CYAN, 300)

set_red(duty), set_green(duty), set_blue(duty)

These methods allow you to set the three channels separately. They take one parameter which is the duty cycle for that channel of betweem 0.0 (off) and 1.0 (full brightness).

set_color_rgb(rgb_string)

This method sets the LED color to an internet color value of the form #FF0000. That is a # followed by a six digit hexadecimal string. The six digit string comprises three two character hex value for the red, green and blue channels.

rgb.set_color('#FF0000') # red

Connect a Raspberry Button

Plug in a switch between the following pins (it does not matter which way around the leads are):

  • GND
  • GPIO 25

Importing the library

from button import *

Creating an Instance

button = Button(25)

The parameter is the pin that the button is connected to. There is also an optional second parameter of the debounce period (in seconds) to prevent false triggerings due to contact bouncing.

button = Button(25, debounce=0.1)

checking for button press

button.is_pressed()

This will return true if the button is pressed and will block and wait until the button has been released and the debounce period has elapsed.

Check out the example programs in the /examples folder of this library.

How to Make Your Own Squid

You will need

To make your own Squid, you will need the following parts:

  • An RGB common cathode diffuse LED (the bigger the better)
  • 3 x 470 Ohm resistors
  • Red, green, blue and black Female to Female jumper wires cut in half
  • 4 short lenths of heat shrink

You will also need soldering equipment and a hot air gun.

Parts

Step 1. Prepare the LED

Leave the longest lead (common cathode) untouched, but trim the other leads as shown below.

Preparing the LED

A apir of helping hands will - well - help.

Step 2. Solder on the resistors

Trim the resistor leads and solder one end to each of the three short anode leads on the LED.

Soldering the Resistors

When all the resistors are soldered, it will look like this.

soldering the Resistors

Step 3. Solder on the header wires

Slip the heat shrink sleaving over the wires BEFORE soldering the wires to the resistor wires and the common cathode. Use red for the red anode, green for bgreen and blue for blue and use a black wire for the common cathode.

soldering the header wires

Step 4. Shrink the sleave

Push the heat shrink sleaves right up to the body of the LED and then shrink the wires using a hot air gun.

shrinking the sleave

squid's People

Contributors

simonmonk 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.