Pages: [1]   Go Down
Author Topic: My first Arduino project  (Read 1452 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

First of all, thanks to Grumpy_Mike and CrossRoads for getting me started with the TLC5940 chip interfacing.

This is the circuit I was wanting to build. I am debating whether to leave it as it is or to expand the TLC5940's so that I can run RGB LEDs. The reason for wanting to do this is because I would like to better mimic incandescent/halogen bulbs during the fading process (i.e. orange when dim and bluish white when bright). I am also at some point in time going to need to either run some transistors or MOSFETS to power the multiple LEDs that I will need to drive. The chasers will have 3 LEDs per channel and the LED that fades in will have approximately 15-20 LEDs running off of it so I cannot rely on the 5940 outputs alone. Anyways, here is a video of it up and running. Thanks once again, guys!

Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 309
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

nice work.

btw, you might want to open the video for comments and listing and provide some meaningful title and description. Maybe also a link to your Arduino sources and schematics.

This way, what you did will also be helpful for other people as they'll be able to find your video and your work.

Take care,

FV
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 200
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thor2015,

the board you have your breadboard and other components mounted on looks neat.
Can you provide some details on it?.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Fabio,
  Thank you for the compliment. Believe me, I wouldn't come to an open source forum to get help and info for free and then leave the members high and dry. The video was meant more or less to show progress, that I am trying to make some steps on my own and to thank you guys for the help so far. The intent was to finish the project first and then post the details. However, since you asked to see it and as a sign of good faith that I'm not trying to keep anything from this community, I'll post the code. As far as the schematic goes, I have the Arduino connected to a TLC5940 exactly as described in the example shown in Google code for the TLC5940 with LEDs on channels 2-8 (pins 1-7 on the TLC5940).

Novice,
 The prototyping board I have is a PAD 234 Analog Digital Trainer. You can search for it on Google, but I do not know if they make them for sale anymore. I like it because it has basic test switches and lights built in along with 5 and 12 volt power supplies.

Code:
/*
    Basic Pin setup:
    ------------                                  ---u----
    ARDUINO   13|-> SCLK (pin 25)           OUT1 |1     28| OUT channel 0
              12|                           OUT2 |2     27|-> GND (VPRG)
              11|-> SIN (pin 26)            OUT3 |3     26|-> SIN (pin 11)
              10|-> BLANK (pin 23)          OUT4 |4     25|-> SCLK (pin 13)
               9|-> XLAT (pin 24)             .  |5     24|-> XLAT (pin 9)
               8|                             .  |6     23|-> BLANK (pin 10)
               7|                             .  |7     22|-> GND
               6|                             .  |8     21|-> VCC (+5V)
               5|                             .  |9     20|-> 2K Resistor -> GND
               4|                             .  |10    19|-> +5V (DCPRG)
               3|-> GSCLK (pin 18)            .  |11    18|-> GSCLK (pin 3)
               2|                             .  |12    17|-> SOUT
               1|                             .  |13    16|-> XERR
               0|                           OUT14|14    15| OUT channel 15
    ------------                                  --------

    -  Put the longer leg (anode) of the LEDs in the +5V and the shorter leg
         (cathode) in OUT(0-15).
    -  +5V from Arduino -> TLC pin 21 and 19     (VCC and DCPRG)
    -  GND from Arduino -> TLC pin 22 and 27     (GND and VPRG)
    -  digital 3        -> TLC pin 18            (GSCLK)
    -  digital 9        -> TLC pin 24            (XLAT)
    -  digital 10       -> TLC pin 23            (BLANK)
    -  digital 11       -> TLC pin 26            (SIN)
    -  digital 13       -> TLC pin 25            (SCLK)
    -  The 2K resistor between TLC pin 20 and GND will let ~20mA through each
       LED.  To be precise, it's I = 39.06 / R (in ohms).  This doesn't depend
       on the LED driving voltage.
    - (Optional): put a pull-up resistor (~10k) between +5V and BLANK so that
                  all the LEDs will turn off when the Arduino is reset.

    If you are daisy-chaining more than one TLC, connect the SOUT of the first
    TLC to the SIN of the next.  All the other pins should just be connected
    together:
        BLANK on Arduino -> BLANK of TLC1 -> BLANK of TLC2 -> ...
        XLAT on Arduino  -> XLAT of TLC1  -> XLAT of TLC2  -> ...
    The one exception is that each TLC needs it's own resistor between pin 20
    and GND.

    This library uses the PWM output ability of digital pins 3, 9, 10, and 11.
    Do not use analogWrite(...) on these pins. */

#include "Tlc5940.h"

const int buttonPin = 2;     // the number of the pushbutton pin
int buttonState = 0;

void setup()
{
  /* Call Tlc.init() to setup the tlc.
     You can optionally pass an initial PWM value (0 - 4095) for all channels.*/
  Tlc.init();
  pinMode(buttonPin, INPUT);
    
}

/* This program utilizes an Arduino Uno and a TLC5940 chip to generate a simple chaser pattern. In addition to the chaser, there is an active mode where a set of auxiliary lights are faded in and held for a period of 10 seconds. */

void loop()
{
  buttonState = digitalRead(buttonPin);
  int bright = 0;
  int direction = 1;
  
  if (buttonState == LOW)
  {
    for (int channel = 1; channel < 7; channel += direction)
    {
      bright = 0;
      Tlc.clear();
      direction = 1;
      Tlc.set(channel, 1000);
      Tlc.update();
     delay(21);
    }
  }
  if (buttonState == HIGH)
  {
    bright = 0;
    do
    {
      if (bright < 1000)
      {
        do
        {
         for (int channel = 1; channel < 7; channel += direction)
         {
           Tlc.clear();
           Tlc.set(7 , bright);
           direction = 1;
           Tlc.set(channel, 1000);
           Tlc.update();
           bright = bright + 50;
           delay(21);
         }
        }
        while (bright < 1000);
       }
        if (bright >= 1000 && bright < 4093)
        {
          do{
          for (int channel = 1; channel < 7; channel += direction)
          {
            Tlc.clear();
            Tlc.set(7 , bright);
            direction = 1;
            Tlc.set(channel, bright);
            Tlc.update();
            bright = bright + 50;
            delay(21);
          }
          }while (bright < 4093);
        }
        if (bright > 4093)
        {
          Tlc.set(1, 4095);
          Tlc.set(2, 4095);
          Tlc.set(3, 4095);
          Tlc.set(4, 4095);
          Tlc.set(5, 4095);
          Tlc.set(6, 4095);
          Tlc.set(7, 4095);
          bright = 4095;
          Tlc.update();
        
          delay(10000);
        }              
       } while (bright < 4095);
     }  
   }
« Last Edit: December 12, 2010, 10:02:04 pm by thor2015 » Logged

Pages: [1]   Go Up
Jump to: