User login

Powered by Drupal, an open source content management system

Theory and Practice of Tangible User Interfaces

Disco Lights

Submitted by naryasece on Wed, 10/15/2008 - 21:56

Assignment: DC Motor: Actuation Assignment 1

Collaborators:

Assignment: DC Motor: Actuation Assignment 1
Collaborators:

For this project, I tried to make a disco light mixer with the motor and three LEDs. I used code from the earlier LED fade project I did, and mixed that with the Pot controls motor code. Since I did not have a glass mirror ball, I improvised with a ball of foil. I think it would have worked, but the motor had trouble going slow enough to just move the light around and not cause seizures. I really needed a proper gear system to provide more torque to move around the ball. Unfortunately, when the motor moves slowly, it has a hard time turning over. The LEDs did make good mood lighting.

disco ball!

Parts Used:

3 LEDs

3 220 ohm resistors

1 10k resistor

1 Transistor

1 Diode

1 Potentiometer 

 

Code:


 

// Fading LED 

// by BARRAGAN <http://people.interaction-ivrea.it/h.barragan> 

 

int value9 = 0;                            // variable to keep the actual value 

//int ledpin = 9;                           // light connected to digital pin 9, commented out for various reasons

int value10 = 127;

int value11= 255; 

int val=0;

void setup() 

  // nothing for setup 

  //analogWrite(9, 24);

 

void loop() 

 

 

  //Code for pin 9

  for(value9 = 0 ; value9 <= 255; value9+=5) // fade in (from min to max) 

  { 

    analogWrite(3, value9);           // sets the value (range from 0 to 255) 

    delay(30);                            // waits for 30 milli seconds to see the dimming effect 

       val = analogRead(1);    // read the value from the sensor, between 0 - 1024

  analogWrite(9, val/4); // analogWrite can be between 0-255

  } 

  for(value9 = 255; value9 >=0; value9-=5)   // fade out (from max to min) 

  { 

    analogWrite(3, value9); 

    delay(30); 

       val = analogRead(1);    // read the value from the sensor, between 0 - 1024

  analogWrite(9, val/4); // analogWrite can be between 0-255

  }  

  //Code for pin 10

  for(value10 = 0 ; value10 <= 255; value10+=5) // fade in (from min to max) 

  { 

    analogWrite(5, value10);           // sets the value (range from 0 to 255) 

    delay(30);                            // waits for 30 milli seconds to see the dimming effect 

       val = analogRead(1);    // read the value from the sensor, between 0 - 1024

  analogWrite(9, val/4); // analogWrite can be between 0-255

  } 

  for(value10 = 255; value10 >=0; value10-=5)   // fade out (from max to min) 

  { 

    analogWrite(5, value10); 

    delay(30); 

       val = analogRead(1);    // read the value from the sensor, between 0 - 1024

  analogWrite(9, val/4); // analogWrite can be between 0-255

  }  

 

  //Code for pin 11

  for(value11 = 0 ; value11 <= 255; value11+=5) // fade in (from min to max) 

  { 

    analogWrite(6, value11);           // sets the value (range from 0 to 255) 

    delay(30);                            // waits for 30 milli seconds to see the dimming effect 

       val = analogRead(1);    // read the value from the sensor, between 0 - 1024

  analogWrite(9, val/4); // analogWrite can be between 0-255

  } 

  for(value11 = 255; value11 >=0; value11-=5)   // fade out (from max to min) 

  { 

    analogWrite(6, value11); 

    delay(30); 

       val = analogRead(1);    // read the value from the sensor, between 0 - 1024

  analogWrite(9, val/4); // analogWrite can be between 0-255

  }  

 

Disco ball green!