User project:WD lights
From uCtrl.net
| This project is under development. |
Contents |
Information
Hello, --1oooop 08:51, 14 July 2010 (UTC) here... I took apart my WD drive and sort of "reverse engineered" the lights I'm planning to put a pico-itx computer inside the case The lights on the case will be operated by an ATmega8L (L because that's all I have lying around)
Primary objective
to make a computer that looks (almost) exactly like a WD drive
The diagram
Slight modifications
I removed a resistor and a capacitor from the SW to +5
the metal plate inside the drive has been remove because of logistic problems
Aesthetic modifications
the sides will be sanded and painted to remove the WD sign
the back ports have been painted red for no apparent reason :D
The program (written in C)
/* Special thanks to Pete Mills By Brandon Lu http://www.uctrl.net WD display "emulator" find me on facebook... http://www.facebook.com/brandon.lu2 find me on the freenode IRC network... p1oooop */ #include <avr/io.h> #include <util/delay.h> uint8_t whee; uint8_t power; uint8_t HDD; uint8_t set1_new; uint8_t set2_new; uint8_t hddstate; uint8_t set1_cur; uint8_t set2_cur; void setup(void){ // port config DDRD &= ~(1<<1); // set PD1 to "0" for input from power DDRD &= ~(1<<0); // set PD0 to "0" for input from HDD DDRB |= ((1<<2) | (1<<3)); // set portB bits 2,3 to 1 for output - PWM PORTD &= ~((1<<2) | (1<<3)); // set the outputs low // PWM config /* OCR0A is for A,C OCR1AL is for B,D */ // Timer/Counter0: channel:A clear on compare match, Fast PWM, TOP = 0xff TCCR1A |= ((1<<COM1A1) | (1<<WGM11) | (1<<WGM10)); TCCR1B |= (1<<CS00); // internal clock as source, no prescale // Timer/Counter1: Channel:A/B clear on compare match, Fast PWM, 8-bit, TOP = 0x00ff TCCR1A |= ((1<<COM1A1) | (1<<COM1B1) | (1<<WGM10)); TCCR1B |= ((1<<WGM12) | (1<<CS10)); // finish up WGM bits, internal clock as source, no prescale } int main(void) { setup(); while(1) { power = PIND & (1<<1); HDD = PIND & (1<<0); if (HDD > 0) {whee = 2;} else { if (power > 0) {whee = 1;} else {whee = 0;} } if (whee == 1) {set1_new = 255; set2_new = 255;} if (whee == 0) {set1_new = 0; set2_new = 0;} if (whee == 2) {if (hddstate == 1) {set1_new = 255; set2_new = 0; hddstate = 2;} if (hddstate == 2) {set1_new = 0; set2_new = 255; hddstate = 1;} } if (set1_cur < set1_new) {++set1_cur;} if (set1_cur > set1_new) {--set1_cur;} if (set2_cur < set2_new) {++set2_cur;} if (set2_cur > set2_new) {--set2_cur;} OCR1A = set1_cur; // set PWM registers for RGB value OCR1AL = set2_cur; _delay_ms(50); // adjust this if you think it's too fast }; return 0; }
Insert non-formatted text here