Would this circuit be usable for making a Knight Rider effect such as pictured below?
Of course there would only be 8 lights and i do not know how bright to expect them to be. But if you added wires to space the LED's appart slightly and made some type of housing to evenly disperse the light, is this do-able using the MiniPOV kit? I'm trying to immagine how quickly the lights 'cycle'.
Thanks,
-Ryan
using POV to do Knight Rider effect?
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 12
- Joined: Mon Sep 10, 2007 12:27 pm
What a quick response!
I ordered a kit this weekend and I have not decided what to do with it yet. i just saw it @ Make! and thought "That's cool, I want one!". Maybe i'll try for an 'LED scanner' or maybe I'll built it conventionally and order more kits for other projects.
I was really intimidated about trying my hand at 'building' a circuit but it looks like you have streamlined the process to make it easy for a beginner. Also there is so much great info here to help me figure out WTF i'm doing. Thanks!
I ordered a kit this weekend and I have not decided what to do with it yet. i just saw it @ Make! and thought "That's cool, I want one!". Maybe i'll try for an 'LED scanner' or maybe I'll built it conventionally and order more kits for other projects.
I was really intimidated about trying my hand at 'building' a circuit but it looks like you have streamlined the process to make it easy for a beginner. Also there is so much great info here to help me figure out WTF i'm doing. Thanks!
-
- Posts: 2
- Joined: Wed Sep 26, 2007 11:25 am
I built the POV3 kit and loaded a few different programs into it. I can't seem re save any edited programs. I would also like to get the testled.c code program back on it but can not seem to find it any where. I assume that my in abillity to save edited programs is due to my not using the right editor(notepad?) or being un able to save it as a file type(.c?) But mostly because this is all very Greek to me! I am trying and learning but the curve seems to be high at the moment.
Please advise
Thank you
Please advise
Thank you
- darus67
- Posts: 246
- Joined: Wed Sep 26, 2007 10:25 pm
Improved Cylon/KITT scanner program
I whipped up an improved scanning LED program tonight. It uses PWM to fade out the trailing LED.
Here's the code. Its even heavily commented so someone other than ME might stand a chance of understanding it.
Enjoy
Here's the code. Its even heavily commented so someone other than ME might stand a chance of understanding it.
Enjoy
Code: Select all
/**************************************************************************
This program will cause the LEDs on the MiniPOV3 to scan back & forth,
with the trailing LED fading out, similar to the old school Cylons
from the original Battlestar Galactica or KITT from Knight Rider
This code is released into the public domain, with no warranty.
Do with it what you will, but harm none.
If it breaks, you get to keep all the pieces.
darus67
20 October 2007
**************************************************************************/
#include <avr/io.h> // this contains all the IO port definitions
#define FADE_RATE 12 // the larger this value, the slower
// the LED will fade
#define INITIAL_WIDTH 128 // the starting value of the PWM pulse
// this is about 50% pulse width
void fade(char bit){
/**************************************************************************
Use pulse width modulation to cause LEDs on Port B to fade out
LEDs corresponding to high bits in 'bit' will fade out
**************************************************************************/
unsigned char rate = FADE_RATE;
unsigned char pulse_width = INITIAL_WIDTH;
unsigned char count;
while(pulse_width){ // as long as pulse_width is non-zero
// loop through the PWM routine
PORTB |= bit; // turn on the LED
for(count=0; count<pulse_width; count++){ // count up to pulse_width
// Do nothing for 1 clock cycle
asm("NOP");// If this is not here, the compiler may
// remove the empty delay loop
}
PORTB &= ~bit; // turn off the LED
for(; count; count++){ // count starts where it left off
// and continues up until it rolls over
// from 255 to 0
asm("NOP"); // Do nothing for 1 clock
}
if(!rate--){ // Decrement rate. If it hits zero then
pulse_width--; // decrement pulse_width and
rate = FADE_RATE; // reset rate
// When pulse_width hits zero, the while loop
} // terminates and the function returns
} // end while
} // end fade
int main(void) {
char b; // a byte to keep track of the lit LED
DDRB = 0xFF; // Set Port B to all outputs
while(1){ // loop forever
// scan from right to left, with the trailing LED fading out.
for(b=0x02; b; b<<=1){ // Instead of incrementing, b gets shifted left.
// When the 1 bit shifts off the left side
// b == 0 and the loop terminates
PORTB = b; // turn on the LED
fade(b>>1); // call fade to fade out the LED to the right of
// the currently lit one
}
// scan from left to right, with the trailing LED fading out
for(b=0x40; b; b>>=1){ // We're shifting b right instead of left this time
PORTB = b; // turn on the LED
fade(b<<1); // fade the LED to the left of the lit one
}
} // end while
} // end main
-
- Posts: 2
- Joined: Wed Sep 26, 2007 11:25 am
- darus67
- Posts: 246
- Joined: Wed Sep 26, 2007 10:25 pm
You should be able to copy and paste it into notepad and then save as cylon.c
Next you'll have to edit your Makefile
Look for the section that looks like this:
program-minipov: minipov.hex
program-all_leds: all_leds.hex
program-test_leds: test_leds.hex
program-alt_leds: alt_leds.hex
program-mypov: mypov.hex
program-test_sensor: test_sensor.hex
now add a line that says
program-cylon: cylon.hex
and save the Makefile
Now you should be able to do:
make program-cylon
and it will compile the program and load it onto your MiniPOV
Next you'll have to edit your Makefile
Look for the section that looks like this:
program-minipov: minipov.hex
program-all_leds: all_leds.hex
program-test_leds: test_leds.hex
program-alt_leds: alt_leds.hex
program-mypov: mypov.hex
program-test_sensor: test_sensor.hex
now add a line that says
program-cylon: cylon.hex
and save the Makefile
Now you should be able to do:
make program-cylon
and it will compile the program and load it onto your MiniPOV
-
- Posts: 1119
- Joined: Wed Jun 13, 2007 9:17 am
- darus67
- Posts: 246
- Joined: Wed Sep 26, 2007 10:25 pm
- jaydmdigital
- Posts: 5
- Joined: Sat Nov 21, 2009 6:38 pm
Re: using POV to do Knight Rider effect?
Modified the posted code for two trailing LEDs. The second one is set to be 1/16th of the first trailing LED. I am using superbright LEDs so this worked for me, but might be too high for other LEDs.
Jay
Jay
Code: Select all
/**************************************************************************
This program will cause the LEDs on the MiniPOV3 to scan back & forth,
with the trailing LED fading out, similar to the old school Cylons
from the original Battlestar Galactica or KITT from Knight Rider
This code is released into the public domain, with no warranty.
Do with it what you will, but harm none.
If it breaks, you get to keep all the pieces.
darus67
20 October 2007
**************************************************************************/
#include <avr/io.h> // this contains all the IO port definitions
#define FADE_RATE 12 // the larger this value, the slower
// the LED will fade
#define INITIAL_WIDTH 64 // the starting value of the PWM pulse
// this is about 50% pulse width
void fade(char bit1, char bit2){
/**************************************************************************
Use pulse width modulation to cause LEDs on Port B to fade out
LEDs corresponding to high bits in bits 'bit1' and 'bit2' will fade out
**************************************************************************/
unsigned char rate = FADE_RATE;
unsigned char pulse_width = INITIAL_WIDTH;
unsigned char count;
while(pulse_width){ // as long as pulse_width is non-zero
// loop through the PWM routine
PORTB |= bit1|bit2; // turn on the LED
for(count=0; count<(pulse_width/16); count++){ // count up to pulse_width for the second LED is 1/16th the first one
// Do nothing for 1 clock cycle
asm("NOP");// If this is not here, the compiler may
// remove the empty delay loop
}
PORTB &= ~bit2; // turn off the second LED
for(count=0; count<pulse_width; count++){ // count up to pulse_width for the first LED
// Do nothing for 1 clock cycle
asm("NOP");// If this is not here, the compiler may
// remove the empty delay loop
}
PORTB &= ~bit1; // turn off the first LED
for(; count; count++){ // count starts where it left off
// and continues up until it rolls over
// from 255 to 0
asm("NOP"); // Do nothing for 1 clock
}
if(!rate--){ // Decrement rate. If it hits zero then
pulse_width--; // decrement pulse_width and
rate = FADE_RATE; // reset rate
// When pulse_width hits zero, the while loop
} // terminates and the function returns
} // end while
} // end fade
int main(void) {
char b; // a byte to keep track of the lit LED
DDRB = 0xFF; // Set Port B to all outputs
while(1){ // loop forever
// scan from right to left, with the trailing LED fading out.
for(b=0x02; b; b<<=1){ // Instead of incrementing, b gets shifted left.
// When the 1 bit shifts off the left side
// b == 0 and the loop terminates
PORTB = b; // turn on the LED
fade(b>>1,b>>2); // call fade to fade out the two LEDs to the right of
// the currently lit one
}
// scan from left to right, with the trailing LED fading out
for(b=0x40; b; b>>=1){ // We're shifting b right instead of left this time
PORTB = b; // turn on the LED
fade(b<<1,b<<2); // fade the two LEDs to the left of the lit one
}
} // end while
} // end main
-
- Posts: 168
- Joined: Wed Jan 16, 2008 5:41 pm
Re: using POV to do Knight Rider effect?
How easy would it be to speed the left to right scan of the led's in this firmware ?
Edit sorry I figured it out just after I asked
#define INITIAL_WIDTH 64 // the starting value of the PWM pulse
// this is about 50% pulse width
Edit sorry I figured it out just after I asked
#define INITIAL_WIDTH 64 // the starting value of the PWM pulse
// this is about 50% pulse width
- tcharron
- Posts: 59
- Joined: Tue Oct 13, 2009 7:15 pm
-
- Posts: 16
- Joined: Fri Dec 12, 2008 5:17 am
Re: using POV to do Knight Rider effect?
I can't figure out how to get this code to compile.
I've used darus67's advice from above:
1. Copied the cylon code into a new cylon.c file
2. Added a new line to the Makefile: "program-cylon: cylon.hex"
However, when I try running "make program-cylon", I get an error: "make: *** No rule to make target `cylon'. Stop."
I don't understand AVR programming well enough to know what's going wrong here. Any advice would be appreciated!
I've used darus67's advice from above:
1. Copied the cylon code into a new cylon.c file
2. Added a new line to the Makefile: "program-cylon: cylon.hex"
However, when I try running "make program-cylon", I get an error: "make: *** No rule to make target `cylon'. Stop."
I don't understand AVR programming well enough to know what's going wrong here. Any advice would be appreciated!
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: using POV to do Knight Rider effect?
just rename the cylon.c code to one of the existing code examples, that way you dont have to worry about the makefile
-
- Posts: 16
- Joined: Fri Dec 12, 2008 5:17 am
Re: using POV to do Knight Rider effect?
That did it, thanks!
But I'd like to understand what's happening here in a little more depth. Why is it that "program-eyebeam: eyebeam.hex" works, but "program-cylon:cylon.hex" fails?
But I'd like to understand what's happening here in a little more depth. Why is it that "program-eyebeam: eyebeam.hex" works, but "program-cylon:cylon.hex" fails?
Please be positive and constructive with your questions and comments.