Show Posts
Pages: [1] 2 3
1  Using Arduino / LEDs and Multiplexing / Re: Price of laser diodes are burning my toast on: May 09, 2011, 06:17:27 am
You're going to need a lot of LEDs and lenses to get to the point that you can cook toast with them.
2  Community / Exhibition / Gallery / Re: ArduPilotMega QuadCopter on: May 06, 2011, 07:46:26 am
3  Community / Exhibition / Gallery / Re: RFID Meter with ID-12, answers "Did I already take this pill?" on: March 21, 2011, 04:14:47 pm
This is a really good idea and a great project.  With a few refinements - LED or LCD display (to display frequency etc..) and RTC - this good be an excellent project and really valuable/useful end result.
4  Using Arduino / LEDs and Multiplexing / Re: Looking for multiple RGB LED fading code, help please! on: March 21, 2011, 11:56:24 am
I find the best way to manage multiple "things" in code is to first represent them in code. 

To do this with 2 (or more) RGB LEDs I would first create a structure representing the state of an LED -

Code:
struct colour {
  byte r;
  byte g;
  byte b;
};

struct led {
  struct colour col;
  struct colour dest;
 byte delay;
};

What I have here is a led with 2 "colours", col being the current colour - this is what is written out by the routine that sets the colours, using whatever method you have for controlling your LEDs - in my case this was for controlling some bliptronics LEDs.

The dest colour is the intended colour.

Then all you need in your main loop is to loop around your LEDs, increment or decrement each Red, Green and Blue colour value in the direction of the destination colour value.  When nothing needed incrementing/decrement you have reached that colour and can do whatever is necessary to select a new destination colour.

Once all LEDs have been altered, loop again and output the colours.

Some snippets of my code - the show_cycle routine picks the next colour from colour_sequence.  I also have a delay status to enable differing change speeds per LED -
Code:
struct colour sequence[] = {
  { 0x1F, 0, 0   },
  { 0x1F, 0, 0x1F   },
  { 0, 0, 0x1F   },
  { 0, 0x1F, 0x1F   },
  { 0, 0x1F, 0   },
  { 0x1F, 0x1F, 0   },
  { 0x1F, 0x1F, 0x1F   },
};

struct led leds[NUM_LEDS];

int seq_pos=0;

void setup() {
  byte Counter;


  // setup/run the fast spi library
  FastSPI_LED.setLeds(NUM_LEDS);
  FastSPI_LED.setChipset(CFastSPI_LED::SPI_LPD6803);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_HL1606);
  //FastSPI_LED.setChipset(CFastSPI_LED::SPI_595);
  // this is the default, but included here to show where/how to change it
  FastSPI_LED.setCPUPercentage(50);
  FastSPI_LED.init();
  FastSPI_LED.start();

  for (int n=0;n<NUM_LEDS; n++) {
    leds[n].col.r=0;
    leds[n].col.g=0;
    leds[n].col.b=0;
    leds[n].dest.r=0;
    leds[n].dest.g=0;
    leds[n].dest.b=0;
    leds[n].delay=0;
  }


  show();

}

void show()
{
  unsigned char *pData = FastSPI_LED.getRGBData();
  for(int i=0; i < NUM_LEDS; i++) {
    *pData++ = (leds[i].col.g << 3);
    *pData++ = (leds[i].col.b << 3);
    *pData++ = (leds[i].col.r << 3);
  }
  FastSPI_LED.show();
}

int move_led(struct led * l) {
  int flg=0;
  if (l->delay==0) {
    if (l->dest.r > l->col.r)      {
      l->col.r++;
      flg++;
    }
    else if (l->dest.r < l->col.r) {
      l->col.r--;
      flg++;
    }
    if (l->dest.g > l->col.g)      {
      l->col.g++;
      flg++;
    }
    else if (l->dest.g < l->col.g) {
      l->col.g--;
      flg++;
    }
    if (l->dest.b > l->col.b)      {
      l->col.b++;
      flg++;
    }
    else if (l->dest.b < l->col.b) {
      l->col.b--;
      flg++;
    }
  }
  else {
    l->delay--;
    flg++;
  }

  return(flg);
}

unsigned int phase;
void loop() {
  int n;
  int flg=0;

  for (n=0;n<NUM_LEDS;n++) flg += move_led(&leds[n]);

  if (flg==0) {
      show_cycle();
  }
  show();
  delay(DELAY);
}

void show_cycle() {
  int n,r;
  seq_pos++;
  r = random(0,4);
  if (seq_pos>= sizeof(sequence)/sizeof(colour)-1 ) seq_pos=0;
  for (n=0;n<NUM_LEDS; n++) {
    leds[n].dest.r=sequence[seq_pos].r;
    leds[n].dest.g=sequence[seq_pos].g;
    leds[n].dest.b=sequence[seq_pos].b;
    switch(r) {
    case 0:
      if (n > (NUM_LEDS/2)) leds[n].delay = (n - (NUM_LEDS/2)) * 10;
      else leds[n].delay=abs(n-5) * 10;
      break;
    case 1:
      leds[n].delay=n*10;
      break;
    case 2:
      leds[n].delay=(NUM_LEDS-1-n) * 10;
      break;
    case 3:
      break;
    case 4:
      if (n > (NUM_LEDS/2)) leds[n].delay = n * 10;
      else leds[n].delay= (NUM_LEDS-1-n) * 10;
      break;
    }
  }
}

5  Using Arduino / General Electronics / Re: Help identifying a component on: March 18, 2011, 03:57:36 am
Here's a pic....
6  Using Arduino / General Electronics / Re: Help identifying a component on: March 17, 2011, 03:58:14 pm
Hmm typing on iPad is dangerous.  That's eBay and triac :o
7  Using Arduino / General Electronics / Help identifying a component on: March 17, 2011, 03:25:59 pm
I've bought a load of components off bay - mostly 1000s of LEDs but also some other bits and pieces (300 micro switches, 1000 bridge rectifiers etc..). Not bad for 40 quid.

Amongst this lot is 250 'things' that I cannot identify. They are a 3pin component similar to a trice or a voltage regulator. The label on it has R3253 and X8425 on it.  The heat sink has Italy stamped on it.  They came in a bag with Gi46064 hand written on it.

Anyone got any ideas what they are ?
8  Using Arduino / LEDs and Multiplexing / Re: Tri-state Multiplexing on: March 10, 2011, 07:38:26 am
Aren't you assuming that there is no drop across each LED ?
9  Community / Exhibition / Gallery / Re: Hexome on: March 01, 2011, 10:30:32 am
hmm - have just read up and apparently a water jet cutter is better than laser for acrylics.  Going to get some to try it now smiley
10  Community / Exhibition / Gallery / Re: Hexome on: March 01, 2011, 10:11:28 am
Here's hoping Birmingham get a Fab Lab soon - I think I would virtually live there smiley

I have access to a massive flat bed water jet cutter (at an aerospace company my brother runs) but really need some specific plastic cuts.
11  Community / Exhibition / Gallery / Re: Hexome on: March 01, 2011, 09:10:38 am
That's a fantastic quality build Mike.

Where do you get your plastics cut ?
12  Development / Other Hardware Development / Re: Entry-level Oscilloscope on: February 28, 2011, 08:34:56 am
Expensive too.
13  Using Arduino / LEDs and Multiplexing / Re: TLC5940 Woes on: February 11, 2011, 04:03:56 am
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286580054
14  Using Arduino / LEDs and Multiplexing / Re: TLC5940 Woes on: February 11, 2011, 03:56:12 am
Yes - that library. Someone posted on the old forum that they had made some changes to solve the problem - I think on was to do with timings. I'll have a good search when I am at my pc.
15  Using Arduino / LEDs and Multiplexing / Re: TLC5940 Woes on: February 10, 2011, 04:20:36 pm
The stock tlc5940 Library is buggy - did this for me also.  Theres some info on the old forum about it - I can't find it atm but someone wrote their own lib that solved it.
Pages: [1] 2 3