« P-COMP FINAL FOR THE CLASS | Main | ARDUINO MINI »

P-COMP LIGHT DIMMER PROJ.

So, i finished assembling the light dimming kit and am waiting for the AD558 chip to interface the dimmer to the Arduino, or better to a ATMEL 16 chip. But here is the code that Tom helped me with for the chip:

/*
DAC pins: digital I/O 6 - 13
*/

void setup() {
//set pins as outputs:
for (int i = 6; i < 14; i++) {
pinMode(i, OUTPUT);
}
}

void loop() {
// fade from 0 to 255:
for (byte i = 0; i < 256; i++) {
setDAC(i);
delay(10);
}
}

void setDAC(byte DAClevel) {
byte thisValue = 0;
for (int i = 6; i < 14; i++) {
// read the appropriate bit from DAClevel:
if ( DAClevel & (1< thisValue= 1;
//will have to figure out a randomizer formula for the flickering effect
}
else {
thisValue= 0;
}
// turn on or off the pin based on the value of the bit:
digitalWrite(i, thisValue);
}
}

TrackBack

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