Pages: [1]   Go Down
Author Topic: Knight Rider 4 with 8x 12v LED modules and a pot  (Read 1766 times)
0 Members and 1 Guest are viewing this topic.
Mercer, PA USA
Offline Offline
Jr. Member
**
Karma: 2
Posts: 55
Arduino & Led's Rock:-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This project is intended to make a bunch of small leds in a row flash back and forth to look like the car on knight rider

In this case the hardware is 8 mini blue LED modules $2.50ea (http://www.usledsupply.com/shop/smd-blu­e-3528-mini-led-modules.html) running at 12v DC so a Darlington Transistor Array (ULN2803A) is needed and connected to the 8 output pins on the Arduino, it is also fed (-) 12v to the GND pin and all the leds are fed (+) 12v so only the (-) is switched with the Transistor Array the (ULN2803A) is rated at 500mA/Ch and there are 8Ch but we are only driving 2x 20mA leds per channel so there is plenty of power left

i also used a pot so you can change the speed of the effect on the fly without having to reprogram it

For a video of it


For instructions, pictures, wiring diagram and code visit
http:// http://fritzing.org/projects/arduino-knight-rider-with-8-blue-12v-led-modules/

* Enjoy

i am new at this programing thing and this is only my 2nd program (other then a few blink and demo sketches) so if there is anything i should do different please let me know so i can learn the right way
as my 1st project isn't done yet and much more complicated (making a RF Remote control for the Arduino) to control led strips or anything really but i am planing to use it for LED strips at first.

well here is my mess of a code   // i tried to explain everything as best i could so other new people can figure out how it works as that is how i learned but also so i could figure out what i did, lol  ;D


Code:
/* Knight Rider 4
 * by Desta Courtney  questions desta@usLEDsupply.com        parts of code based on "Knight Rider 3" by David Cuartielles
 *
 * This project is intended to make a bunch of small leds in a row flash back and forth to look like the car on knight rider
 * In this case the hardware is 8 mini blue LED modules (from usLEDsupply.com) running at 12v DC so a Darlington Transistor Array (ULN2803A) is needed and connected to the
 * 8 output pins on the arduino it is also fed (-) 12v to the GND pin and all the leds are fed (+) 12v so only the (-) is switched with the (ULN2803A)
 * the (ULN2803A) is rated at 500mA/Ch and there are 8Ch but we are only driving 2 20mA leds per channel so there is plenty of power left
 
 * I also used a pot on analog input (0) so you can change the speed of the effect on the fly without having to reprogram it (it is also mapped to an adjustable range for better control)
 
 * Enjoy
 * There is a video of it working on YouTube (just search "usLEDsupply" or "Knight Rider Arduino" and you should find it) or instructions on http://fritzing.org/profiles/usLEDsupply/
 */

 int pinArray[] = {2, 3, 5, 6, 9, 10, 11, 12};  // lists the pins the leds are attached to
 byte count = 0;     // used so the program knows where it is in the sequnce
 int timer = 50;   // is used for the map function
 
 // you can adjust the numbers below to set te max and min for the speed adjustment
 int x = 0;        // sets the max speed (0 = fast) the lower the number the faster it can go
 int y = 100;      // sets the min speed (100 = slow) the higher the number the slower it can go



 void setup(){
      
      for (count=0;count < 8;count++) {      // sets all the pins in the array as outputs
      pinMode(pinArray[count], OUTPUT);      // sets all the pins in the array as outputs
 }
      }

 void loop() {
      
      
      for (count=0;count < 7;count++) {         // cycles threw all the leds in the array
      digitalWrite(pinArray[count], HIGH);      // turns the first led on
      delay(timer);                             // sets the delay (for how fas it will go)
      digitalWrite(pinArray[count + 1], HIGH);  // turns the next led on
      delay(timer);                             // sets the delay (for how fas it will go)
      digitalWrite(pinArray[count], LOW);       // turns it back off
      delay(timer);                             // sets the delay (for how fas it will go)

        timer = analogRead(0);               // reads the pot and sets the timer to the value
        timer = map(timer, 0, 1023, x, y);   // maps the timer value to the max and min vaues set above with x and y
 }
  
  
      for (count=7;count > 0;count--) {        // same thing but in reverse so it will end up going back and forth
      digitalWrite(pinArray[count], HIGH);
      delay(timer);
      digitalWrite(pinArray[count - 1], HIGH);
      delay(timer);
      digitalWrite(pinArray[count], LOW);
      delay(timer);

        timer = analogRead(0);               // reads the pot and sets the timer to the value (this is the same as above but is reading it again so you don't have to waut as long to see the speed changes)
        timer = map(timer, 0, 1023, x, y);   // maps the timer value to the max and min vaues set above with x and y
 
      }
      }
« Last Edit: October 05, 2010, 11:56:40 am by wediggers » Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ouch, that was bad enough in the TV-Series. Now if you manage to add David Hasselhoff: Double Ouch.

Korman
Logged

Mercer, PA USA
Offline Offline
Jr. Member
**
Karma: 2
Posts: 55
Arduino & Led's Rock:-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

ohh come on now kitt was cool
i use to watch that show along with MacGyver:-)
Logged

Central Europe
Offline Offline
Edison Member
*
Karma: 7
Posts: 1220
Use the Source, Luke.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

MacGyver was cool, he could make a surface-air missile out of some twisted wire, a tube of toothpaste and half a can of baked beans, as long as he still had his pocket knife.

Knight Rider was awful, specially the version with German dubbing. It was even worse than T.J. Hooker. The only good thing that came out of that series is that I never ever will call anyone Pardner.

Korman
« Last Edit: October 05, 2010, 01:04:39 pm by Korman » Logged

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

interesting thread!
Logged

Mercer, PA USA
Offline Offline
Jr. Member
**
Karma: 2
Posts: 55
Arduino & Led's Rock:-)
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry i must have miss-typed the link in the first post for the mini blue LED modules i used as it doesn't seem to work
http://www.usledsupply.com/shop/smd-blue-3528-mini-led-modules.html
Logged

Pages: [1]   Go Up
Jump to: