# Blink an led for 10 sec in knight rider

I am making a knight rider and in that particular case i want an one led remains blinking till x time and then it should goes to another led as knight rider. so somebody please help me to programming i am geting diffcuilty as i am beginner so please help me and i am using audrino uno

I don't get the 10 seconds... or exactly what you want to do with the timing...

I'm old enough to remember the TV show, but I don't know what the exact sequence looks like (such as if there was more than one LED/light on at a time) or how many LEDs/lights there were. I also suspect they used incandescent lamps because IIRC the light would decay instead of "snapping" on & off instantly like an LED.

I'm sure you can find examples, but if you want to try making it yourself start with the basic "Blink" example and try to understand how it works. Then add a couple more LEDs and make them blink in sequence. Then add a few more steps to make the sequence reverse.

If you want it to stop after 10 seconds, look at the Blink Without Delay example. That shows you how to make a timer that doesn't "freeze" your program like delay(). Then, you use an if-statement to stop the loop when the time is up.

You can still use delay() to blink the LEDs if you wish, but your longer timer can't use delay(). Most real-world programs avoid delay() because your program can't do anything during the delay() time.

When you make your timer, don't make the loop stop when the time exactly equals 10 seconds. Make it stop when the time is greater than or equal to 10 seconds.

After you get the basic sequence working, make it into a simpler loop. For example, each time through the loop, the LED variable changes so that a different LED comes on & off. There are for-loops, while() loops and do-while loops. In this case, a for-loop is probably best because it automatically counts the number of loops.

You'll probably need one loop for one direction and another loop for another direction.

This is going to be too advanced for you right now so you might want to ignore it - For my sequencing effects I use bitwise operations where each bit represents the state of one LED. Then, "sequencing" is done by simple bit-shifting.

So, let's say I have a byte (8-bits) representing 8 LEDs.

A simple chase-sequence looks like this:

00000001 00000010 00000100 00001000... etc...

There is also something called a Johnson Counter that looks like this: (I'll show a 4-bit version to make it simpler.)

0000 0001 0011 0111 1111 1110 1100 1000 0000

Of course, these patterns can be reversed and there are other interesting patterns.

DVDdoug: I'm old enough to remember the TV show, but I don't know what the exact sequence looks like (such as if there was more than one LED/light on at a time) or how many LEDs/lights there were. I also suspect they used incandescent lamps because IIRC the light would decay instead of "snapping" on & off instantly like an LED.

There was a substantial decay in the "tail" of the scan, making it much smoother than a simple step and this would have been quite deliberate and not merely a side effect of using incandescent bulbs.

Yes, of course they used incandescent lamps because this was back in 1982!

I remember Knight Rider too

A shadowy flight into the dangerous world of a man who does not exist 8)

Kitt`s Lights

Arduino KnightRider Tutorial