Programmable IC for leds

Thread Starter

c.marsh

Joined May 16, 2009
100
Hi everyone,

I'm a little new to this sort of stuff so please bare with me.

I have an arduino Uno board and software and I have a little experience with programming on that.

I spend my hobby time doing scale models of various sci fi and motorcycle based stuff. Usually I use hardware like 555 timer chips to control lighting and so on, but I'm starting a new project, a 1/6 scale motorcycle which I would really like to have all the lights working on it.

So I was thinking of a tiny circuit with an IC at its heart controlling the lighting in cycles,

for example:

Power on
Head light comes on dipped beam
rear light comes on
<time lapse 2 minutes>
left indicators turn on <time on 15 seconds>
rear brake turns on for 1 second, off for 2 seconds on for 1 second
Left indicators turn off
<time lapse 2 minutes>
right indicators turn on <time lapse 15 seconds>
rear brake turns on for 1 second, off for 2 seconds on for 1 second
right indicators turn off
<time lapse 2 minutes>
headlight turns to high beam
<Time lapse 2 minutes>
headlight turns to dipped beam
<Return to beginning of program and loop until turned off?

Now I can do with real easy on the arduino as I have some code put together for control star trek federation star ships lighting and its pretty universal for this kind of lighting projects.

The thing is, the arduino is complete and utter overkill for this kind of thing and far to big to go inside a 1/6 scale motorcycle tank/engine casings.

So I was wondering if anyone knows of an IC/microchip that I can program using the arduino sketch to control the lights?

i guess it would need the following channels:

1 - headlight dipped beam
2 - headlight full beam
3 - rear light
4 - rear brake
5 - left indicators
6 - right indicators

As i said, im new to programmable IC's and any help would be greatly appreciated.

Oh, I'd also like to keep the power requirements to a minimum, I can run 2 power wires INTO the motorcycle and have a battery source external from the bike.
 

kubeek

Joined Sep 20, 2005
5,795
Just use whatever chip your arduino uses standalone and put the code inside it? you don´t need the whole board, but you do need to program the chip, for example using ponyprog, or right inside the arduino if it is a dip package chip.
Or do that small step and learn progamming AVRs and put the program in any avr that suits your needs.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
The arduino chip is atmega328p-pu but is a bit big really

Is there a smaller variant?

when you say program the chip, what do you mean? I know it needs the code to run the lights but what sort of code to get the chip to run that code?
 

kubeek

Joined Sep 20, 2005
5,795
I am not too familiar with arduino, but basically the arduino environment creates a binary file that you can load into the chip. With the arduino the original chip has a pre-loaded part that allows you to easily upload your code.
A chip that you buy from a shop will not contain this and you need other means of loading the code - a programmer, but these can be quite easy to make.
But really if you require to a smaller chip the easiest way to do it is to write the code straight in C and then program the chip, without using the arduino libraries.

First you should start with deciding how many pins you need to controle the LEDs and then go to atmel.com and choos a suitable chip. They even send free samples for some of them.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
Okay well i need 6 channels + power input.

I will look on amtel and see if I can work out which is suitable and post here for confirmation :)

Thanks for the help, im sure i'll be back for oppinions on the best interface device to use and help on getting the enviroment programming working.
 
@c.marsh

What type of leds are going to be used? What is their power or current rating? What is the dimensions of the engine case cavity that is going to hold the driver? Would something like 17mm dia. by 10mm high work?

A bare ATtiny25 can be had in a small skinny SOIC pkg., and has four PWM registers that should handle the situation. This would assume a single led for headlight and tail light. Don't konw if it has an been ported to Arduino or not. Also, I think Dimension Engr. makes a blinky kit for the RC folks that is user programmable.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
SMD is fine,

The actual led lights are SMD anyway.

I'll be making the PCB myself using photoresist hopefully, otherwise i'll get a pcb made up by a company.

I'll take a look at the tutorial in a little while as im writing up an arduino sketch just to see how things will run with what i have in mine.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
@c.marsh

What type of leds are going to be used? What is their power or current rating? What is the dimensions of the engine case cavity that is going to hold the driver? Would something like 17mm dia. by 10mm high work?

A bare ATtiny25 can be had in a small skinny SOIC pkg., and has four PWM registers that should handle the situation. This would assume a single led for headlight and tail light. Don't konw if it has an been ported to Arduino or not. Also, I think Dimension Engr. makes a blinky kit for the RC folks that is user programmable.
Sorry I missed your post,

The leds will be smd style, the headlight and rear light will have 2 smd led each, the dimensions sound good as a 1/6 tank or engine casings should have a good amount of space in them.
 
Sorry I missed your post,

The leds will be smd style, the headlight and rear light will have 2 smd led each, the dimensions sound good as a 1/6 tank or engine casings should have a good amount of space in them.
SMD could mean 2ma to 3A or more, which is the reason I asked about the current rating. I have already developed a small (16mm) four channel, high power (350-1000ma), constant current LED driver. You could consider it a slave board to the Arduino or ATtiny, PIC etc. LED's need to be at minimum 1W though, and would be dimmed by PWM from the micro.

 
O.K. those can be directly driven from the microcontroller pins with the appropriate current limiting resistors. Just watch that you don't go over the overall package limitation which is typically around 200ma. If you get in a pinch, then you can use shift register chip like the 74HC595. My solution is wayyyyy overboard, unless you want BRIGHT.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
there is only 180ma draw at peak, so just fits into the typical limitation it seems :D

Now i just need to work out which chip exactly to use and try to get it setup and write the light code in C.

I wrote the code in arduino just as a test bed for timings and patterns, looks okay as a motorcycle light system.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
Rich (BB code):
// Motorcycle Prototype Mk1

#include <LedFader.h>
#include <LedFlasher.h>

// pin assignments PMW 3,5,6,9,10,11
const byte DippedPin = 1;          // 
const byte HighPin = 2;            // 
const byte RightIndicatorPin = 3;  //
const byte LeftIndicatorPin = 4;   // 
const byte RearLightPin = 5;       // 
const byte RearBrakePin = 6;       // 


// Flashers                     pin                  off-time  on-time       on?
LedFlasher LeftIndicator    (LeftIndicatorPin,        500,       500,     false);
LedFlasher RightIndicator   (RightIndicatorPin,       500,       500,     false);
LedFlasher RearBrake        (RearBrakePin,            700,       2000,     false);

// states for the state machine
typedef enum
  {
  initialState,
  wantDippedBeam,
  wantHighBeam,  
  wantHighBeamOff,
  wantLeftIndicator,            
  wantRightIndicator,
  wantLeftIndicatorOff,
  wantRightIndicatorOff,
  wantRearLight,
  wantRearBrake,
  wantRearBrake2,
  wantRearBrakeOff,
  wantRearBrakeOff2,  
  } states;

// state machine variables
states state = initialState;
unsigned long lastStateChange = 0;
unsigned long timeInThisState = 1000;

void setup ()
  {
  pinMode (DippedPin, OUTPUT);
  pinMode (HighPin, OUTPUT);
  pinMode (RearLightPin, OUTPUT);
    
  // set up faders, flashers  
  LeftIndicator.begin ();
  RightIndicator.begin ();
  RearBrake.begin ();
  }  // end of setup
        
void doStateChange ()
  {
  lastStateChange = millis ();    // when we last changed states
  timeInThisState = 1000;         // default one second between states

  switch (state)
   {
    case initialState:
         state = wantDippedBeam;
         break;
         
    case wantDippedBeam:
         digitalWrite (DippedPin, HIGH);
         state = wantRearLight;
         break;
         
    case wantRearLight:
         digitalWrite (RearLightPin, HIGH);
         state = wantRearBrake;
         timeInThisState = 20000;
         break;
//left Indicators/brake Lights
    case wantRearBrake:
         RearBrake.on();
         state = wantLeftIndicator;
         break;
         
    case wantLeftIndicator:
         LeftIndicator.on();
         state = wantRearBrakeOff;
         timeInThisState = 5000;
         break;
         
    case wantRearBrakeOff:
         RearBrake.off();
         state = wantLeftIndicatorOff;
         break;
    
    case wantLeftIndicatorOff:
         LeftIndicator.off();
         state = wantHighBeam;
         timeInThisState = 20000;
         break;
         
    case wantHighBeam:
         digitalWrite (HighPin, HIGH);
         state = wantRearBrake2;
         break;
         
    case wantRearBrake2:
         RearBrake.on();
         state = wantRightIndicator;
         break;
         
    case wantRightIndicator:
         RightIndicator.on();
         state = wantRearBrakeOff2;
         timeInThisState = 5000;
         break;
         
    case wantRearBrakeOff2:
         RearBrake.off();
         state = wantRightIndicatorOff;
         break;
         
    case wantRightIndicatorOff:
         RightIndicator.off();
         state = wantHighBeamOff;
         timeInThisState = 20000;
         break;
         
    case wantHighBeamOff:
         digitalWrite (HighPin, LOW);
         state = wantDippedBeam;
         break;
                
    }  // end of switch on state
  }  // end of doStateChange


void loop ()
  {
   if (millis () - lastStateChange >= timeInThisState)
     doStateChange ();
   // update faders, flashers
   RearBrake.update ();
   LeftIndicator.update ();
   RightIndicator.update ();

  }  // end of loop
thats the arduino code. is it of any use on a stand alone chip?
 

kubeek

Joined Sep 20, 2005
5,795
I didn´t know arduino had this capability to program other chip through the main board, so yes I think that if you follow that instructable it should work nice. Also you can check is the arduino supports more than just those two attiny chips.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
yeah i downloaded a file for other chips, i just need to select one of the supported chips that meets the power requirements, pinout requirements and of course size requirements.

So far im sitting on the ATtiny24 which is a 14 pin 12i/o chip. theres some additional downloading and setup for that chip but seems a good choice to go with.
 

Thread Starter

c.marsh

Joined May 16, 2009
100
decided on the at85 chip and odering one soon.

hopefully there wont be any problems and i can report back in a few days with a video of it working away.
 
Last edited:
Top