« THREE OPTIONS | Main | NEW IDEA FOR AUDIO PIECE »

FINISHED THE LIGHT DIMMER PROGRAM

FINALLY, PROGRESS

light.jpg

And finally I finished the light dimmer. Almost. The Arduino code works fine, i am not sure how good it is for the life of the bulb, but it's visually what i was looking for.
Now i am waiting for the shipment of the actualy lamp from Italy and the assembly will be complete.

ARDUINO CODE


/*
DAC pins: digital I/O 6 - 13
*/
int time;
long randNumber;

void setup() {
Serial.begin(9600);
//set pins as outputs:
for (int i = 6; i < 14; i++) {
pinMode(i, OUTPUT);
}
time = millis();
randomSeed(time);
}

void loop() {
setDAC(random(255));
delay(random(200));
delay (10);
}

void setDAC(byte DAClevel) {
byte thisValue = 0;
for (int k = 6; k < 14; k++) {
// read the appropriate bit from DAClevel:
if ( (DAClevel & (1<<(k-6))) >0 ) {
thisValue= 1;
}
else {
thisValue= 0;
}
// turn on or off the pin based on the value of the bit:
// Serial.print(thisValue, DEC);
digitalWrite(k, thisValue);
}
Serial.println(DAClevel, DEC);
}

VIDEO

Download file

TrackBack

TrackBack URL for this entry:
http://itp.nyu.edu/~bp432/cgi-bin/mt/mt-tb.cgi/60