Pages: [1]   Go Down
Author Topic: Car led system or CARduino  (Read 1068 times)
0 Members and 1 Guest are viewing this topic.
suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Porting this over from the old forums. Combined all of my relevant posts into this one, all new posts will be separate.

So, high everyone! I'm new here and to the whole world of arduino but I'm eager to learn!

So I'm here to get your opinions on my next project and hopefully get some questions answered.

My newest project: Arduino controlled led system.

What I am hoping to accomplish is a multi “zoned” led system for my car.
I participate in various things that allow me to use warning lights on my vehicle, some things are for a local government agency and some is for other things that involve police escorts.  Currently I have a cheap led flasher from China that I bought off of ebay before the foreign sellers started jacking their shipping charges.  The flasher came with 2 sets of lights with each set having 3 pods of 3 leds.  The flasher has 3 patterns, mode A is side 1 flashes 4x then side 2 flashes 4x, mode B is alternating flash (1,2,1,2,1,2,1,2,1,2,1,2…..), mode C is both sides at the same time.   These leds are amber and are mounted in the rear window.  Since getting the flasher I have added some white led strips in the grill and tied them into the wires for the other lights.
So I don't have many lights and would like to add more.  But real warning leds are expensive and I don't have a few hundred to drop into that. What I would like to do is have an arduino control all the leds around the car independently.  Attached is a map of the different “zones” that I would like to control.  The front and rear have two zones so the leds can have alternating flash patterns. 
There are a few goals I have for this project to be able to do.
1.      Individual zone control. (on, off, strobe, etc…)
2.      Preset patterns or modes. (zones 11+12 alternate, zones 21,22,23,24 on, etc…)
3.      Use a LCD display to scroll through the zones and modes.
Bonus Goals!!
4.      Use RGB leds and control each color channel in the zones.
5.      Have an additional zone for a traffic advisor (arrow stick).
So my first question is what arduino would I need to have this work?  The interior zones are just extra that I thought would be cool to have a glow from under the seats and dash.  So could I get by with an Uno or would I need a Mega?
I know others have driven high powered leds from an arduino before so that not a huge issue.



The numbers would be the area of each zone.  I numbered them in the 10's, 20's and 30's so I know what area of the car is that zone without having to think about how I numbered them. 10's would be exterior zones and 20's would be interior zones.  I added the 30's as a last minute thing, but I think I'll just add them to them to the 10's zones.


Me again!

Well I got my Uno and have been doing every tutorial I can find!

Since my last postings I've made a couple of changes.

First I'm not going to use the joystick I posted about earlier.  I've since found a library for a wii nun-chuck that only uses 2 pins for the joystick, button, and accelerometer.  Just finished this, will be in first "new" post.

And I've also found a strand of RGB leds that each led is individually addressable and only uses 2 pins. http://www.adafruit.com/index.php?main_page=product_info&cPath=37&products_id=322

I've got almost every individual part of the system working separately now I just need to combine it all.

My biggest hurdle is the menu format that I'll navigate on the lcd.  I've not found a great way to learn how to do that, so I'm on the hunt for that.

Another small step is finding a transistor that is high enough amperage for a car battery but works at low enough voltage.  I bought one at radioshack and it worked but I didn't pay attention to the amps on the package and my home-built bench power supply (old atx power supply) made the transistor release the magic smoke.  Got correct mosfets and have them working with a 10k pulldown resistor

Logged

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Progress on the CARduino!

I have finally got the nunchuck working. It took a lot of help from a friend that's knowledgeable in C and bits and pieces of code from about 3 different examples of how to use the nunchuck with an arduino. But we got it to work. So now the arduino returns the position of the joystick and the status of the two buttons on the nunchuck. (also the accelerometers but I'm not going to be using them)

Next step is to convert this sketch into a library so I can include it in the menu system code and use the values of the joystick and buttons to navigate the menu.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 43
Even a broken clock is right twice a day!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi there Crimson.
I am not a english native ,so please escuse any mistakes i make.I saw your post and thought about some car improvements and i liked the idea.I have sticked some leds on my car too and i would like to be able to command them invidually.I have an arduino and an 128x64 Lcd with Ks0108 driver on it.Currently learning how to display on it using the library.
As i thought i would like to have 5 buttons(like a joystick) for control and a nice menu to be able to turn the led-s on or off,and in the same time i would add a drawing picture with my car on lcd,to animate the openings of the doors,the light when turn on or off,and even the stereo.Later i might add the time and maybe some car info(like speed or acc).
As i was saying i dont have nothing installed on the car,just trying buttons on my breadboard and the Lcd.
I would love to see what you have done so far,to have a point of inspiration.
As i am an electrical engineer,the hardware part is a lot easy for me,than the software.If i can be of any help,please PM me.
Daniel!
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 126
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been doing something similar over the last year for my motorcycle.
http://arduino.cc/forum/index.php/topic,8381.0.html

I started it last spring.  But then the weather got warm and I would rather spend my time on the motorcycle smiley  I was also delayed because customs held my bliptronic leds for a couple of months.

I have gone through 4 different designs because I keep adding features.  I'll give you a quick summary of what I have done and why.
My original plan was to make some accent LEDs that I can control and make custom effects.  I wanted to control them remotely and I wanted the ability to add effects later on easily.  I found a 4 button remote.  I will have a microsd card holding animation information.  Some animations have to be programmed - anything that has random numbers.  The microsd card will will contain frame based effects. 

I started with a tlc5947 led driver chip as that is the first thing I came across in my research.  The first video in that post is me making sure I can control the chip.  Those LEDs are once I had around and they are a pain to work with.  I found a led strip on ebay that takes 12v (perfect for a car or bike) that could be cut and used like individual LEDs with the tlc chip.  I got that all working fine.

Then I saw the Bliptronic pixel LEDs.  I really liked that idea over the tlc5947 because it would be a lot less wiring.  In a car, you can hide wires in door panels and such.  On a motorcycle, not so much.  So I picked up some of those.  They work great but I ran into a problem.  Since you have to manually control the PWM cycle that takes up processing power.  Some of my more complex animations affected that causing the LEDs to flicker. 

Luckily, the next week Sparkfun came out with their addressable LED strip.  The chip they use has it's own PWM cycle.  That is a super easy LED strip to work with.

Right now I am in the process of converting the code to a Netduino Plus.  The Netduino Plus has built in ethernet and microsd.  This gives me more I/O pins for future expansion.  Plus the fact that I can do line by line debugging makes it easy to code. I am going to use a small wifi router connected to the ethernet port and control it with my ipod touch instead of the remote.

I am still going to finish the project with the Arduino as my sister wants the basic setup on her bike.  One idea for future expansion is to use xbee or some other wireless communication between my bike and my sister's bike to have in sync animations when our bikes are next ot each other.

When I ordered the Bliptronic LEDs I also grabbed the audio analyzer shield.  I will add some modes where the LEDs are controlled by music.

Finally, FYI, the US government definition of amber warning lights is actually orange.  100% red, 50% green.  I was going to use my LEDs as running lights (anything to make a motorcycle more visible) but running lights are only legal on trucks and emergency vehicles.
Logged

South Louisiana
Offline Offline
Full Member
***
Karma: 0
Posts: 178
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an ongoing project i work on in my free time similar to this.

Here is a link to Tundra Geeks website where i have some videos, even though you can't see them too well.
http://tundrageeks.com/forum/showthread.php?t=2486&page=1

I think i have made some minor mods to the code since this, i have some functions in here that weren't even being called at this time.

The LED's are in each front door handle of my truck, each rear door handle and on the passenger and (soon to be) driver foot well. 

Code:
/*

Program to do all kind of goofy crap with the LED's in my door handles

*/

const int fg = 4; // Assign each color for each handle ex: fg = Front Green and rr = Rear Red
const int fb = 3; // Interior light are tied to front door handles
const int fr = 2;
const int rg = 7;
const int rb = 6;
const int rr = 5;

const int colorIn = 15;
const boolean intlights = 48;

const boolean alarmIn = 52;

float colorValue = 0; //setting variables for later
int repeatCount = 1;
int alarmOffCount = 1;
int trueValue = 0;
int sampleTotal = 0;
long totalValue = 0;
int randomCheck;

void setup () {

pinMode (fg, OUTPUT); // Assign all pins
pinMode (fb, OUTPUT);
pinMode (fr, OUTPUT);
pinMode (rg, OUTPUT);
pinMode (rb, OUTPUT);
pinMode (rr, OUTPUT);

pinMode (colorIn, INPUT);
pinMode (intlights, INPUT);
pinMode (alarmIn, INPUT);

digitalWrite (intlights, HIGH); //Set inputs to maintain high
digitalWrite (alarmIn, HIGH);

digitalWrite (fg, LOW); // Turn all LED's off initially
digitalWrite (fb, LOW);
digitalWrite (fr, LOW);
digitalWrite (rg, LOW);
digitalWrite (rb, LOW);
digitalWrite (rr, LOW);

randomSeed(analogRead(0));

Serial.begin(9600);

}

void loop () {

/* Removed because no random patterns are needed
int totalPatterns = 8; //total numbers of patterns to pick from during random selection

int randomValue = random(1, totalPatterns + 1); //generate a random value for the next pattern to run

if (randomCheck == randomValue && randomCheck <= totalPatterns - 1){ //if the last pattern is the same as the one about to run go to next pattern
randomValue = randomValue + 1;
}
else if (randomCheck == randomValue && randomCheck == totalPatterns) { //if the last pattern was the last one in the series then go back one instead
randomValue = randomValue - 1;
}

randomCheck = randomValue; //set a varible to make sure the same pattern doesn't repeat
*/


if ( digitalRead (alarmIn) == HIGH && alarmOffCount == 0 ) {
alarmOffCount = 1;
ledFade (fr, fb, fg, rr, rg, rb, 35, .5, 5); // white fade when truck is unlocked
}

while (digitalRead (intlights) == LOW && digitalRead (alarmIn) == HIGH){ //code for interior lights to change colors selected by 5K pot

totalValue = 0; //reset variables at beginning of loop
trueValue = 0;

for (int i=1; i<=50 ; i++){ //take 50 readings from Analog Input pin
trueValue = analogRead(colorIn);
totalValue = trueValue + totalValue;
sampleTotal = i;
}

colorValue = totalValue/sampleTotal; //get average of 50 readings pulled in from loop

Serial.println(colorValue); // Print average color value to serial port

intLights (0, 175, 0, rr, 0, fr); // takes a value from the pot (0-1023) and uses that value to change the colors on the led
intLights (165, 345, rr, rb, fr, fb);
intLights (335, 515, rb, rg, fb, fg);
intLights (505, 685, rg, rr, fg, fr);
intLights (675, 855, 0, rb, 0, fb);
intLights (845, 1015, 0, rg, 0, fg);

}


while ( digitalRead (alarmIn) == LOW ) { // While viper is armed pin holds to low and the 4 color fade cycle repeats 100 times

alarmOffCount = 0;

for ( repeatCount=1 ; repeatCount<100 ; repeatCount++ ) {
ledFade (fr, 0, 0, rr, 0, 0, 50, 2, 5); //red fade
ledFade (0, fg, 0, 0, rg, 0, 30, .5, 5); //green fade
ledFade (0, 0, fb, 0, 0, rb, 30, 1, 5); //blue fade
ledFade (fr, fb, fg, rr, rg, rb, 30, .5, 5); // white fade

if ( digitalRead (alarmIn) == HIGH ) {
break;
}
}
}

//Notes to refer to when making calls
//ledStrobe (int f1, int f2, int f3, int r1, int r2, int r3, int strobeLow, int strobeHigh, float strobeStep)
//ledFade (int f1, int f2, int f3, int r1, int r2, int r3, int delayTime, float fadeIncrementOn, float fadeIncrementOff)

}




void intLights (int low, int high, int LEDlower1, int LEDraise1, int LEDlower2, int LEDraise2){ //takes the value from the pot and turns it into led values

if(colorValue == 0) {
digitalWrite(rr, LOW);
digitalWrite(fr, LOW);

digitalWrite(rg, LOW);
digitalWrite(fg, LOW);

digitalWrite(rb, LOW);
digitalWrite(fb, LOW);
}

else if(colorValue >1000){
digitalWrite(rr, HIGH);
digitalWrite(fr, HIGH);

digitalWrite(rg, HIGH);
digitalWrite(fg, HIGH);

digitalWrite(rb, HIGH);
digitalWrite(fb, HIGH);
}

else if (colorValue > low && colorValue < high){

int LED1 = map (colorValue, low, high, 255, 10);
int LED2 = map (colorValue, low, high, 10, 255);
int LED3 = map (colorValue, low, high, 255, 10);
int LED4 = map (colorValue, low, high, 10, 255);

analogWrite (LEDlower1, LED1);
analogWrite (LEDraise1, LED2);
analogWrite (LEDlower2, LED3);
analogWrite (LEDraise2, LED4);

}
}


void ledStrobe (int f1, int f2, int f3, int r1, int r2, int r3, int strobeLow, int strobeHigh, float strobeStep){

for (float strobeSpeed = strobeLow; strobeSpeed <=strobeHigh; strobeSpeed +=strobeStep){ //shift pf and df from flash speed at strobeLow to flash speed at strobeHigh
digitalWrite (f1, HIGH);
digitalWrite (f2, HIGH);
digitalWrite (f3, HIGH);
delay(strobeSpeed);
digitalWrite (f1, LOW);
digitalWrite (f2, LOW);
digitalWrite (f3, LOW);
delay(strobeSpeed);
}

for (float strobeSpeed = strobeHigh; strobeSpeed >=strobeLow; strobeSpeed -=strobeStep){ //shift pf and df from flash speed at strobeHigh to flash speed at strobeLow
digitalWrite (f1, HIGH);
digitalWrite (f2, HIGH);
digitalWrite (f3, HIGH);
delay(strobeSpeed);
digitalWrite (f1, LOW);
digitalWrite (f2, LOW);
digitalWrite (f3, LOW);
delay(strobeSpeed);
}

for (float strobeSpeed = strobeLow; strobeSpeed <=strobeHigh; strobeSpeed +=strobeStep){//shift pr and dr from flash speed at strobeLow to flash speed at strobeHigh
digitalWrite (r1, HIGH);
digitalWrite (r2, HIGH);
digitalWrite (r3, HIGH);
delay(strobeSpeed);
digitalWrite (r1, LOW);
digitalWrite (r2, LOW);
digitalWrite (r3, LOW);
delay(strobeSpeed);
}

for (float strobeSpeed = strobeHigh; strobeSpeed >=strobeLow; strobeSpeed -=strobeStep){//shift pr and dr from flash speed at strobeHigh to flash speed at strobeLow
digitalWrite (r1, HIGH);
digitalWrite (r2, HIGH);
digitalWrite (r3, HIGH);
delay(strobeSpeed);
digitalWrite (r1, LOW);
digitalWrite (r2, LOW);
digitalWrite (r3, LOW);
delay(strobeSpeed);
}

}


void ledFade (int f1, int f2, int f3, int r1, int r2, int r3, int delayTime, float fadeIncrementOn, float fadeIncrementOff){

for (float fadeValue = 0; fadeValue <=255 ; fadeValue +=fadeIncrementOn) { //fade door led's to on
analogWrite (f1, fadeValue);
analogWrite (f2, fadeValue);
analogWrite (f3, fadeValue);
analogWrite (r1, fadeValue);
analogWrite (r2, fadeValue);
analogWrite (r3, fadeValue);
delay(delayTime);

if ( digitalRead (alarmIn) == HIGH ){ //check to see if alarm is still armed
digitalWrite (fg, LOW); // Turn all LED's off
digitalWrite (fb, LOW);
digitalWrite (fr, LOW);
digitalWrite (rg, LOW);
digitalWrite (rb, LOW);
digitalWrite (rr, LOW);
repeatCount=1;
loop ();
}
}

for (float fadeValue = 255; fadeValue >=0 ; fadeValue -=fadeIncrementOff) { //fade door led's to off
analogWrite (f1, fadeValue);
analogWrite (f2, fadeValue);
analogWrite (f3, fadeValue);
analogWrite (r1, fadeValue);
analogWrite (r2, fadeValue);
analogWrite (r3, fadeValue);
delay(delayTime);

if ( digitalRead (alarmIn) == HIGH ){ //check to see if alarm is still armed
digitalWrite (fg, LOW); // Turn all LED's off
digitalWrite (fb, LOW);
digitalWrite (fr, LOW);
digitalWrite (rg, LOW);
digitalWrite (rb, LOW);
digitalWrite (rr, LOW);
repeatCount=1;
loop ();
}
}

digitalWrite (fg, LOW); // Turn all LED's off
digitalWrite (fb, LOW);
digitalWrite (fr, LOW);
digitalWrite (rg, LOW);
digitalWrite (rb, LOW);
digitalWrite (rr, LOW);

if ( digitalRead (alarmIn) == HIGH ){ //check to see if alarm is still armed
repeatCount=1;
loop ();
}

delay(1000);

if ( digitalRead (alarmIn) == HIGH ){//check to see if alarm is still armed
repeatCount=1;
loop ();
}

}

Logged

suburb of Chicago, IL
Offline Offline
Newbie
*
Karma: 0
Posts: 20
Arduino newb.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies, apparently this new forum's thread notifier is broken because I didn't get any emails when you posted. smiley-sad

@DanielIt:  I've thought of having a graphic lcd as well, maybe with a touch screen so I can just tap the area of the car I want to be on, but that uses a LOT of pins and would force me to use shift registers.  That's not horrible but like you the hardware is the easy part for me, I'm learning as I go along with the coding part and shift registers just add another level of complexity.  Now if I had a mega instead of an Uno I would look more into that idea.

@SirPoonga: I like the bike idea, I've been toying with doing something like that once this is finished.  I have a '02 Harley V-Rod.  It already has some lights on it, but they are just on or off.  I ride with them on all the time, lucky for me most of the cops around here know that a more visible bike is a safer bike and they don't mind the lights if they aren't flashing.

@Goofballtech:  I like the door handles.  I'll take a look at your code for some ideas, but I'll admit that it's a bit above me at the moment.  The rgb leds will be secondary in this project so after I get all of flashers working, I'll see what kind of space I have left on the chip for the code for the rgb's. 
Logged

Pages: [1]   Go Up
Jump to: