/* DARNIT simulator v1.00 DARNIT was a lightshow device that was built using an 8 bit shift register, a simple audio amp, an inverter, and a few caps. The audio input was run through a 100hz lowpass filter, and amplified from line level. This output was shoved through an inverter to get the audio to TTL level, and clip it. This was then run through another cap to debounce, and reduce the number of triggers. That was then run back throguh the inverter. The output from that was run into the clock input on the serial-in, 8 bit out shift register. Each of the 8 bits was tied to an LED as well as a few solid state relays. The input for the shift register was hooked through another inverter and to one of the output lines. As the music generates bass (usually on the beat, at least), it would send a flurry of clock triggers to the shift register which would display a pattern on the LEDs. This update is only the logic portion of it. Analog 0 selects which output pin to invert and use as the input for the shifter. Digital 2-9 are the output of the shifting. (hook up LEDs) Digital 12 is the input from the audio amp. (hook up a switch for now) Digital 2-9 <--------/\/ 220 ohm /\/----[LED]----> GND +------> +5 power | Digital 12 <-----+----[ switch ]-----/\/ 10k ohm /\/-----> GND [ right pin of 10k pot]---->>+5 power Analog 0<-------[center pin of 10k pot] [ left pin of 10k pot]---->>GND */ boolean shiftData[9]; int outLeds[8] = { 2, 3, 4, 5, 6, 7, 8, 9 }; int inputTrigger = 12; int analogInput = 0; void setup() { /* set up IO */ for( int i=0 ; i<8 ; i++ ) { pinMode( outLeds[i], OUTPUT ); } pinMode( inputTrigger, INPUT ); /* set up bits */ for( int i=0 ; i<9 ; i++ ) { shiftData[i] = LOW; } } void shift() /* shift bits from high index to low index */ { for( int i=0 ; i<8 ; i++ ) { shiftData[i] = shiftData[i+1]; } } int invertPin( int val ) { if( val == HIGH ) { return LOW; } return HIGH; } int lastTrigState; void loop() { /* select the input pin to get the inversion index from */ int idx = analogRead( analogInput ) * 8 / 1024; /* read the input value */ shiftData[8] = invertPin( shiftData[idx] ); /* invert another bit */ int thisTrigState = digitalRead( inputTrigger ); if( lastTrigState == LOW && thisTrigState == HIGH ) { /* the trigger acts as a clock to the shifter */ shift(); } lastTrigState = thisTrigState; /* now blit out the data */ for( int i=0 ; i<8 ; i++ ) { digitalWrite( outLeds[i], shiftData[i] ); } }