martes, 3 de junio de 2008

attiny 2313 knight rider

Hello, Here is a small & easy to build knight rider effect led based board using the atmel at tiny2313 chip.
it's only for test the compiler winavr on my vista lap-top, and it works great, including DASA programer!

please look this video of the device working . . ..



the code (C code) looks like :

/**************************************************************************
darus67
20 October 2007
**************************************************************************/

#include // this contains all the IO port definitions
#define FADE_RATE 20 // 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<<=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);>
**************************************************************************

it compiles error free using Winavr (under PN software)
Winavr can be downloaded H E R E
PN software is also packed with the executable installer

Note that this code fade-out always the last LED emulating true oldest bulbs's filaments that were used on the original effect...

About the programmer:

The software used for download the firmware was AVRDUDE (in winavr) with
DASA variation, it is avery very simple bit-banging programmer, so you only need the serial port and some resistors, diodes and that's all.

About the circuit:

not much to tell, only connect eight LED's on PORT outputs, the oscilator used is the internal one. the con sub-db9 is for programming only.

That's all guys, See ya !



.::Dastechnik::.
.::Hack on ::.




Website counter