/* -------------------------------------------------------------------------------------------------- Master Clock Generator: Script 2 (feb 2008): LSDj PITCH CONTROLE/CLOCK GENERATOR By: Gijs Gieskes 2008 http://gieskes.nl LSDj Clock out on Pins: 10 to 13. something. on analog Pins: a3 to a5 LED: 4. LED: 5. potentiometer on Pin: a0 extra info: When you press button1 it will skip one pulse (of "24" ppqn) on 2 out puts, and the other button will do the same for the other two outputs. So if you have two gameboys with a beat every 4th step and they run in sync, you can press 12 times and end up making them out of sync halfe a beat.. i think. 12 more tabs on the button will make it advance another half beat.. bla die bla.. -------------------------------------------------------------------------------------------------- */ int analogValueA = 0; int SSButton2 = 6; int SSButton1 = 7; int SSRead1 = 0; int SSRead2 = 0; int tellerDelA = 0; int tellerDelB = 0; int upA = 0; int upB = 0; int ledPin1 = 4; int ledPin2 = 5; void setup(){ DDRB = B111111; DDRC = B111100; pinMode(SSButton1, INPUT); pinMode(SSButton2, INPUT); digitalWrite(SSButton1, HIGH); digitalWrite(SSButton2, HIGH); pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); } void loop(){ analogValueA = analogRead(0); analogValueA = 2200+(analogValueA*10); // delay settings SSRead1 = digitalRead(SSButton1); SSRead2 = digitalRead(SSButton2); if (SSRead1 == LOW && upA == 0) { lsdjClock(4, analogValueA); digitalWrite(ledPin1, HIGH); upA = 1; }else if(SSRead1 == HIGH){ digitalWrite(ledPin1, LOW); upA = 0; } if(SSRead2 == LOW && upB == 0) { lsdjClock(3, analogValueA); digitalWrite(ledPin2, HIGH); upB = 1; }else if(SSRead2 == HIGH){ digitalWrite(ledPin2, LOW); upB = 0; } lsdjClock(2, analogValueA); } void lsdjClock(int selectRow, int analogValueA){ if(selectRow == 4){ for (int i=0; i <= 7; i++){ PORTB = B000011; delayMicroseconds(61); PORTB = B110011; delayMicroseconds(61); } delayValue(analogValueA); }else if(selectRow == 3){ for (int i=0; i <= 7; i++){ PORTB = B000011; delayMicroseconds(61); PORTB = B001111; delayMicroseconds(61); } delayValue(analogValueA); }else{ for (int i=0; i <= 7; i++){ PORTB = B000011; delayMicroseconds(61); PORTB = B111111; delayMicroseconds(61); } delayValue(analogValueA); } } void delayValue(int analogValueA){ delayMicroseconds(analogValueA); delayMicroseconds(analogValueA); delayMicroseconds(analogValueA); delayMicroseconds(analogValueA); }