Showing posts with label LED. Show all posts
Showing posts with label LED. Show all posts

Thursday, August 29, 2013

Cube4 by freetronics

Finally my birthday present arrived: the Cube4, a 4x4x4 RGB LED cube by freetronics.The assembly was rather simple due to the good instructions an the freetronics site and the detailed video. Because I've been a little impatient, the cube is not 100% rectangular. The first own skteches were no problem. It's a lot of fun to view the colourful cube.
Unfortunatly I cannot upload sketches since yesterday evening. I'm in contact with John from freetronics. So a word concerning the support of freetronics: wonderful! Quick and competent.

If everything will work again, I will post a video.

Sunday, January 27, 2013

LoL Shield: first own sketch

Next in LoL Shield history: a sort of "growth simulation":

  1. Place a particle (say: light a LED) at a random place on the shield.
  2. start a new particle at (0, 0).
  3. move this particle randomly; north, south, east or west.
  4. if the particle hits a placed one, fix it at its last free place.
  5. repeat from 2. until (0, 0) is occupied.
  6. then blink the result, clear the screen and start at 1.
If the movement crosses a border then move to the other side. Mathematically spoken: we are on a torus.

First a short video (sorry for the poor quality - it seems that google reduces quality extremely):

video


And here is the sketch:


/*  growth01 - simulating a sort of growth.
 *
 *  23 Jan 2013   danimath   created
 *
 **********************************************************************/

#include 
boolean used [14][9];      // array of "used" points
int     x, y;              // actual point
int     xold, yold;        // last point

const int BLINKNUM   =  10; // number of blinks
const int BLINKDELAY = 300; // ms; blink speed
const int MOVEDELAY  =  50; // ms; move speed

/* ****************************************************************** */
void setup ()
{
    LedSign::Init ();
    randomSeed (analogRead(0));
    for (int j = 0;   j < 14;   j++)
    {
        for (int k = 0;   k < 9;   k++)
        {
            used [j][k] = false;
        }
    }
    x = random (14);
    y = random (9);
    LedSign::Set (x, y, 1);
    used [x][y] = true;
    x = y = 0;
}

/* ****************************************************************** */

void loop ()
{
    int dir = random (4);
/*
 *  1. light my fire
 *  ================
 */
    for (int j = 0;   j < 14;   j++)
    {
        for (int k = 0;   k < 9;   k++)
        {
                LedSign::Set (j, k, used [j][k]);
        }
    }
/*
 *  2. get next point
 *  =================
 */
    xold = x;
    yold = y;
    switch (dir)
    {
        case 0:
            x--;
            if (x < 0) x = 13;
            break;
        case 1:
            x++;
            if (x > 13) x = 0;
            break;
        case 2:
            y--;
            if (y < 0) y = 8;
            break;
        case 3:
            y++;
            if (y > 8) y = 0;
            break;
    }
/*
 *  3. check, if used
 *  =================
 */
    if (used [x][y])
    {
        used [xold][yold] = true;
        for (int j = 0;   j < BLINKNUM;   j++)
        {
            LedSign::Set (0, 0, 0);
            LedSign::Set (xold, yold, 0);
            delay (MOVEDELAY);
            LedSign::Set (0, 0, 1);
            LedSign::Set (xold, yold, 1);
            delay (MOVEDELAY);
        }
        x = y = 0;
    }
    LedSign::Set (x, y, 1);
    delay (MOVEDELAY);
/*
 *  4. nothing more possible
 *  ========================
 */
    if (used [0][0])
    {
/*
 *      4.1. blink result
 *      -----------------
 */
        for (int i = 0;   i < BLINKNUM;   i++)
        {
            LedSign::Clear (0);
            delay (BLINKDELAY);
            for (int j = 0;   j < 14;   j++)
            {
                for (int k = 0;   k < 9;   k++)
                {
                    LedSign::Set (j, k, used [j][k]);
                }
            }
            delay (3 * BLINKDELAY);
        }
/*
 *      4.2. clear all
 *      --------------
 */
        for (int j = 0;   j < 14;   j++)
        {
            for (int k = 0;   k < 9;   k++)
            {
                used [j][k] = false;
            }
        }
        x = random (14);
        y = random (9);
        LedSign::Set (x, y, 1);
        used [x][y] = true;
        x = y = 0;
    }
}


LoL Shield assembly

For a long time I'm addicted to blinking LEDs, so it was only natural to buy a LoL Shield by Jimmie P. Rogers. I ordered it at Watterott and - as usual - they delivered very quickly. With trembling hands I unpacked the parts - and decided to wait until tremor disappeared. After reading some descriptions of the assembly and watching this recommendable video from Super Awesome Sylvia. I started to solder the 126 LEDs; a good exercise.

Unfortunately all instructions handle 3 mm LEDs; and there is a pitfall with 5 mm LEDs:
the instructions recommend to solder the headers last, and so did I. But two headers (for the digital pins) have to be soldered between the LEDs:





This was a little bit difficult. Thus I recommend to solder the inner headers first and work with the LEDs from this point. Finally solder the headers at the edge (the analogue ones).


Finally I noticed that the solder joints were so high, that they contacted the USB port of the Arduino, so I used a proto shield as a spacer.


Here is a view of the result:



Next I started the example sketches. They worked rather good, but I had some "ghost LEDs" when LED 42 was lit. I suspected a cold soldering spot, so I re-soldered the LED. Everything was fine - for five minutes, then the ghost LEDs reappeared. Fortunately there were six spare LEDs, and I replaced LED 42. Then everything worked fine.

Next I tried the fonttest example, but this did not work. It seems that there is a bug in the library, so that it does not work wit IDE 1.0.1. Lots of research to do.

Wednesday, August 15, 2012

LED bar shield, Part II

F... I've pimped the LED bar shield with a second shift register, but there seems to be a bug with the soldering. The LED bar shows the first pattern, and nothing more happens.

Saturday, June 16, 2012

LED bar shield, Part I

The LED bar shield shall hold two shift registers 74HC595 and a LED bar with 20 LEDs; 16 LEDs of it will be used. The sketch shall choose randomly one of several patterns and run it five to ten times. Then it selects another one.

The first version of the shield was a disaster - the design was much too small. (And the distance were too small to be soldered by a smoker with old eyes ;-)). So I redesigned it with a larger PCB.

Here are some pictures of the first stage populated with one shift register:





Thursday, May 3, 2012

Evil Spider 2

This is a new version of the evil spider. I've replaced the LED in the head with two smaller LEDs in the eyes. This way the brightening is easier to see.

video

Some close-up photos are at the end of this post - if you fear spiders, scroll slowly down to the image with breadboard ;-)

The source code is rather simple:



/*  Spider - sketch for spider control
 *
 *  12. Apr 2012   danimath   created
 *  02. May 2012   danimath   added blinking
 *
 **********************************************************************/
byte          usPin = 8;       // ultrasound pin
unsigned long usDuration;      // ultrasound duration
unsigned int  cm;              // roughly calculated cm
byte          ledPin = 3;      // LED pin
int           brightness;      // LED brightness
int           min_threshold =  15 ; // treshold for blinking LED
const int     max_threshold = 100; // treshold for brightning LED
const int     mesDelay = 250;  // msec between measurements

//#define DEBUG

/*   setup - initialise things
 *
 **********************************************************************/
void setup ()
{
#ifdef DEBUG
    Serial.begin (9600);
#endif
    analogWrite (ledPin, 255);
    usDuration = getDist ();  // warm up measurement
    delay (2500);
    analogWrite (ledPin, 0);
}

/*   loop - the ever lasting loop
 *
 **********************************************************************/

void loop ()
{
    usDuration = getDist ();
    cm = usDuration / 58;  // int is enough for this
#ifdef DEBUG
    Serial.print   ("usDuration: ");
    Serial.println (usDuration);
#endif
    if (cm < min_threshold)
    {
        if (brightness == 0)
            brightness = 255;
        else
            brightness = 00;
    }
    else if (cm < max_threshold)
        brightness = map (cm, 0, max_threshold, 200, 0);
    else
        brightness = 0;
    analogWrite (ledPin, brightness);
    delay (mesDelay);
}

/*   getDist - gets the distance from SRF05
 *
 *   return value: micro seconds
 *
 **********************************************************************/
unsigned long getDist ()
{
    unsigned long retVal;

    pinMode (usPin, OUTPUT);
    digitalWrite (usPin, LOW);
    delayMicroseconds (2);
    digitalWrite (usPin, HIGH);
    delayMicroseconds (10);
    digitalWrite (usPin, HIGH);

    pinMode (usPin, INPUT);
    retVal = pulseIn (usPin, HIGH);
#ifdef DEBUG
    Serial.print   (retVal);
    Serial.print   (", ");
    Serial.print   (retVal / 58.0);
    Serial.println (" cm");
#endif
    return (retVal);
}


The hardware is just as simple as the software. This image is created with Fritzing. Of course I didn't use a breadboard in the final construction.




As promised here are the close-ups: