vibrating art

the idea is simple:

  • take an old electric toothbrush;
  • add a led and a vibrator;
  • shape something around it;

i am using polycaprolactone (FDA approuved). the schematic is pretty simple, but i had to play with the capacitor and inductor to get more power into the vibrator. it’s overkill to use an attiny for cycling the colors of the led (i didn’t know that you can buy RGB led with built-in pwm). even so, i am sharing the small code, maybe it can be useful to someone. since i am using an electric toothbrush there’s no physical connection to recharge it, thus completely waterproof. i will need to remelt the polycaprolactone to change the battery someday.

 #define F_CPU 9600000UL
 #include <avr/io.h>
 #include <util/delay.h>
 #define LED PB0
 #define LED2 PB1
 int i;
 
 int main (void)
 {
	 DDRB = 0xff;
	 TCCR0A |= ((1 << COM0A1) | (1 << COM0A0) | (1 << COM0B1) | (1 << COM0B0) | (1 << WGM01) | (1 << WGM00)); // WGM01 - WGM00 (set fast PWM)
	 OCR0A = 0; // initialize Output Compare Register A to 0
	 OCR0B = 0;
	 TCCR0B |= (1 << CS01); // Start timer at Fcpu / 256
 
	 for (;;)
	 {
		 for (i = 0 ; i < 255 ; i++ ) // For loop (Up counter 0 - 255)
		 {
			  OCR0A = i; // Update Output Compare Register (PWM 0 - 255)
			 _delay_ms(8);
		 }
		 for (i = 255 ; i > 1 ; i-- ) // For loop (down counter 255 - 0 )
		 {
			 OCR0B = i; // Update Output Compare Register (PWM 0 - 255)
			 _delay_ms(8);
		 }
		 for (i = 255 ; i > 1 ; i-- ) // For loop (down counter 255 - 0 )
		 {
			  OCR0A = i; // Update Output Compare Register (PWM 0 - 255)
			 _delay_ms(8);
		 }
		 for (i = 0 ; i < 255 ; i++ ) // For loop (Up counter 0 - 255)
		 {
			  OCR0B = i; // Update Output Compare Register (PWM 0 - 255)
			 _delay_ms(8);
		 }
	 }
 }

19

12 2010

Your Comment