Build Your Own Clone Message Board

It is currently Wed Dec 02, 2020 3:06 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Effectblade Code
PostPosted: Tue Dec 17, 2013 6:49 pm 
Offline
User avatar

Joined: Thu Jan 03, 2008 12:42 pm
Posts: 2501
Main Chip Version 1 (outdated):

Code:
#include <EEPROM.h>

//pin assigments
const int Preset1_LED_Pin = 0;
const int Preset2_LED_Pin = 1;
const int Preset3_LED_Pin = 2;
const int Preset4_LED_Pin = 3;
const int Preset5_LED_Pin = 4;
const int Preset8_LED_Pin = 9;
const int Preset1_Button_Pin = A5;
const int Preset2_Button_Pin = A4;
const int Preset3_Button_Pin = A3;
const int Preset4_Button_Pin = A2;
const int Preset5_Button_Pin = A1;
const int Preset6_Button_Pin = A0;
const int Preset7_Button_Pin = 13;
const int Preset8_Button_Pin = 12;
//const int Mode_ButtonA_Pin = 11;
//const int Mode_ButtonB_Pin = 10;
const int Shift_Enable_Pin = 6;
const int Shift_Slide_Pin = 7;
const int Shift_Bit_Pin = 8;

int buttonState1 = HIGH;         // variable for reading the pushbutton status
int buttonState2 = HIGH;
int buttonState3 = HIGH;
int buttonState4 = HIGH;
int buttonState5 = HIGH;
int buttonState6 = HIGH;
int buttonState7 = HIGH;
int buttonState8 = HIGH;
int buttonStateA = HIGH;
int buttonStateB = HIGH;
int current_bank = 1;
int current_patch = 1;
//int array[15] = {P6, P7, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, B1, B2, B3};
int array[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};

void setup() {
  pinMode(Preset1_LED_Pin, OUTPUT);   
  pinMode(Preset2_LED_Pin, OUTPUT);   
  pinMode(Preset3_LED_Pin, OUTPUT);   
  pinMode(Preset4_LED_Pin, OUTPUT); 
  pinMode(Preset5_LED_Pin, OUTPUT);   
  pinMode(Preset8_LED_Pin, OUTPUT);   
  pinMode(Preset1_Button_Pin, INPUT_PULLUP);
  pinMode(Preset2_Button_Pin, INPUT_PULLUP);
  pinMode(Preset3_Button_Pin, INPUT_PULLUP);
  pinMode(Preset4_Button_Pin, INPUT_PULLUP);
  pinMode(Preset5_Button_Pin, INPUT_PULLUP);
  pinMode(Preset6_Button_Pin, INPUT_PULLUP);
  pinMode(Preset7_Button_Pin, INPUT_PULLUP);
  pinMode(Preset8_Button_Pin, INPUT_PULLUP);
  //pinMode(Mode_ButtonA_Pin, INPUT_PULLUP);
  //pinMode(Mode_ButtonB_Pin, INPUT_PULLUP);
  pinMode(Shift_Enable_Pin, OUTPUT);   
  pinMode(Shift_Slide_Pin, OUTPUT);   
  pinMode(Shift_Bit_Pin, OUTPUT);
 }
 
 void loop(){
start:
  int changed = 0;
  buttonState1 =digitalRead(Preset1_Button_Pin);
  buttonState2 =digitalRead(Preset2_Button_Pin);
  buttonState3 =digitalRead(Preset3_Button_Pin);
  buttonState4 =digitalRead(Preset4_Button_Pin);
  buttonState5 =digitalRead(Preset5_Button_Pin);
  buttonState6 =digitalRead(Preset6_Button_Pin);
  buttonState7 =digitalRead(Preset7_Button_Pin);
  buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1 == LOW || buttonState2 == LOW || buttonState3 == LOW || buttonState4 == LOW || buttonState5 == LOW || buttonState6 == LOW || buttonState7 == LOW || buttonState8 == LOW){
    delay(100);
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
  }
 
  if(buttonState1==LOW && buttonState8==LOW){goto programmer;}
  if(buttonState7==LOW && buttonState8==LOW){goto bankup;}
  if(buttonState1==LOW && buttonState2==LOW){goto bankdown;}
  if(buttonState1==LOW){current_patch = 1;changed=1;};
  if(buttonState2==LOW){current_patch = 2;changed=1;};
  if(buttonState3==LOW){current_patch = 3;changed=1;};
  if(buttonState4==LOW){current_patch = 4;changed=1;};
  if(buttonState5==LOW){current_patch = 5;changed=1;};
  if(buttonState6==LOW){current_patch = 6;changed=1;};
  if(buttonState7==LOW){current_patch = 7;changed=1;};
  if(buttonState8==LOW){current_patch = 8;changed=1;};

   
  if(changed==1){
  //LED STATUS============================================================
    //bank up
restart:   
  if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
 
  //recall from memory
  array[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  array[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  array[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  array[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  array[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  array[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  array[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  array[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  array[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  array[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));
 
transmit:
  if(current_bank==1) {array[13]=1; array[14]=0; array[15]=0;}
  if(current_bank==2) {array[13]=0; array[14]=1; array[15]=0;}
  if(current_bank==3) {array[13]=0; array[14]=0; array[15]=1;}
  if(current_bank==4) {array[13]=1; array[14]=1; array[15]=0;}

   //bitbang out
    shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
         
    delay(50);
  }//end of changed
goto start; 
 
bankup:
current_bank=current_bank+1;
if(current_bank>=5){current_bank=1;};
//delay(200);
goto transmit;

bankdown:
current_bank=current_bank-1;
if(current_bank<=0){current_bank=4;};
//delay(200);
goto transmit;
 
programmer: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//displayprogram mode
digitalWrite(Preset1_LED_Pin, HIGH);
digitalWrite(Preset2_LED_Pin, HIGH);
digitalWrite(Preset3_LED_Pin, HIGH);
digitalWrite(Preset4_LED_Pin, HIGH);
digitalWrite(Preset5_LED_Pin, HIGH);
array[1] = 1;
array[2] = 1;
digitalWrite(Preset8_LED_Pin, HIGH);
array[3]= 0;
array[4]= 0;
array[5]= 0;
array[6]= 0;
array[7]= 0;
array[8]= 0;
array[9]= 0;
array[10]= 0;
array[11]= 0;
array[12]= 0;
   
//shift out status   
shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
delay(1000);
int z=0;
while(z<=1){
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1==LOW){current_patch = 1;z=5;};
  if(buttonState2==LOW){current_patch = 2;z=5;};
  if(buttonState3==LOW){current_patch = 3;z=5;};
  if(buttonState4==LOW){current_patch = 4;z=5;};
  if(buttonState5==LOW){current_patch = 5;z=5;};
  if(buttonState6==LOW){current_patch = 6;z=5;};
  if(buttonState7==LOW){current_patch = 7;z=5;};
  if(buttonState8==LOW){current_patch = 8;z=5;};
  }
  array[13]= 1;
  array[14]= 1;
  array[15]= 1;
    if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
   
  array[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  array[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  array[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  array[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  array[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  array[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  array[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  array[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  array[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  array[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));

  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
delay(300);

int y=0;
int half=1;
digitalWrite(Preset1_LED_Pin, HIGH);
digitalWrite(Preset2_LED_Pin, HIGH);
digitalWrite(Preset3_LED_Pin, HIGH);
digitalWrite(Preset4_LED_Pin, HIGH);
while(y<=1){
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1==LOW && half==1){
  if(array[3]==1){array[3]=0;}
  else{array[3]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState1==LOW && half==2){
  if(array[8]==1){array[8]=0;}
  else{array[8]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }

  if(buttonState2==LOW && half==1){
  if(array[4]==1){array[4]=0;}
  else{array[4]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState2==LOW && half==2){
  if(array[9]==1){array[9]=0;}
  else{array[9]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState3==LOW && half==1){
  if(array[5]==1){array[5]=0;}
  else{array[5]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState3==LOW && half==2){
  if(array[10]==1){array[10]=0;}
  else{array[10]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }

  if(buttonState4==LOW && half==1){
  if(array[6]==1){array[6]=0;}
  else{array[6]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState4==LOW && half==2){
  if(array[11]==1){array[11]=0;}
  else{array[11]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState5==LOW && half==1){
  if(array[7]==1){array[7]=0;}
  else{array[7]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState5==LOW && half==2){
  if(array[12]==1){array[12]=0;}
  else{array[12]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState8==LOW){
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+0),array[3]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+1),array[4]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+2),array[5]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+3),array[6]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+4),array[7]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+5),array[8]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+6),array[9]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+7),array[10]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+8),array[11]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+9),array[12]);
  y=5;
  digitalWrite(Preset1_LED_Pin, HIGH);
  digitalWrite(Preset2_LED_Pin, HIGH);
  digitalWrite(Preset3_LED_Pin, HIGH);
  digitalWrite(Preset4_LED_Pin, HIGH);
  digitalWrite(Preset5_LED_Pin, HIGH);
  array[1] = 1;
  array[2] = 1;
  digitalWrite(Preset8_LED_Pin, HIGH);
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(1000);
  goto restart;
  }
 
  if(buttonState6==LOW){
  if(half==1){
  half=2;
  digitalWrite(Preset1_LED_Pin, LOW);
  digitalWrite(Preset2_LED_Pin, LOW);
  digitalWrite(Preset3_LED_Pin, LOW);
  digitalWrite(Preset4_LED_Pin, LOW);
  digitalWrite(Preset5_LED_Pin, HIGH);
  array[1] = 1;
  array[2] = 1;
  digitalWrite(Preset8_LED_Pin, HIGH);
  //shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  }
  else{half=1;
  digitalWrite(Preset1_LED_Pin, HIGH);
  digitalWrite(Preset2_LED_Pin, HIGH);
  digitalWrite(Preset3_LED_Pin, HIGH);
  digitalWrite(Preset4_LED_Pin, HIGH);
  digitalWrite(Preset5_LED_Pin, LOW);
  array[1] = 0;
  array[2] = 0;
  digitalWrite(Preset8_LED_Pin, LOW);
  //shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  }
   
   
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }



 delay(1000);
 goto start;
 

}
//end main loop-------------------------------------------------------------------------------------------------------------------------------------------------------------------------




void shiftout(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n,  int o){
int shiftoutarray[16]={0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o};
   for(int i=1; i<17; i++){
      if(shiftoutarray[i]==1){
        digitalWrite(Shift_Bit_Pin, HIGH);
      }
      else {
        digitalWrite(Shift_Bit_Pin, LOW);
     }
     digitalWrite(Shift_Slide_Pin, HIGH);
      delay(1);
      digitalWrite(Shift_Slide_Pin, LOW);
      delay(1);
   }
}



Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Tue Dec 17, 2013 6:50 pm 
Offline
User avatar

Joined: Thu Jan 03, 2008 12:42 pm
Posts: 2501
Main Chip Version 2 (current):

Code:
#include <EEPROM.h>

//pin assigments
const int Preset1_LED_Pin = 0;
const int Preset2_LED_Pin = 1;
const int Preset3_LED_Pin = 2;
const int Preset4_LED_Pin = 3;
const int Preset5_LED_Pin = 4;
const int Preset8_LED_Pin = 9;
const int Preset1_Button_Pin = A5;
const int Preset2_Button_Pin = A4;
const int Preset3_Button_Pin = A3;
const int Preset4_Button_Pin = A2;
const int Preset5_Button_Pin = A1;
const int Preset6_Button_Pin = A0;
const int Preset7_Button_Pin = 13;
const int Preset8_Button_Pin = 12;
const int Mode_ButtonA_Pin = 11;
const int Mode_ButtonB_Pin = 10;
const int Shift_Enable_Pin = 6;
const int Shift_Slide_Pin = 7;
const int Shift_Bit_Pin = 8;

int buttonState1 = HIGH;         // variable for reading the pushbutton status
int buttonState2 = HIGH;
int buttonState3 = HIGH;
int buttonState4 = HIGH;
int buttonState5 = HIGH;
int buttonState6 = HIGH;
int buttonState7 = HIGH;
int buttonState8 = HIGH;
int buttonStateA = HIGH;
int buttonStateB = HIGH;
int current_bank = 1;
int current_patch = 1;
//int array[15] = {P6, P7, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, B1, B2, B3};
int array[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};
int temparray[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};

void setup() {
  pinMode(Preset1_LED_Pin, OUTPUT);   
  pinMode(Preset2_LED_Pin, OUTPUT);   
  pinMode(Preset3_LED_Pin, OUTPUT);   
  pinMode(Preset4_LED_Pin, OUTPUT); 
  pinMode(Preset5_LED_Pin, OUTPUT);   
  pinMode(Preset8_LED_Pin, OUTPUT);   
  pinMode(Preset1_Button_Pin, INPUT_PULLUP);
  pinMode(Preset2_Button_Pin, INPUT_PULLUP);
  pinMode(Preset3_Button_Pin, INPUT_PULLUP);
  pinMode(Preset4_Button_Pin, INPUT_PULLUP);
  pinMode(Preset5_Button_Pin, INPUT_PULLUP);
  pinMode(Preset6_Button_Pin, INPUT_PULLUP);
  pinMode(Preset7_Button_Pin, INPUT_PULLUP);
  pinMode(Preset8_Button_Pin, INPUT_PULLUP);
  pinMode(Mode_ButtonA_Pin, INPUT_PULLUP);
  pinMode(Mode_ButtonB_Pin, INPUT_PULLUP);
  pinMode(Shift_Enable_Pin, OUTPUT);   
  pinMode(Shift_Slide_Pin, OUTPUT);   
  pinMode(Shift_Bit_Pin, OUTPUT);
 }
 
 void loop(){
start:
  int changed = 0;
  buttonState1 =digitalRead(Preset1_Button_Pin);
  buttonState2 =digitalRead(Preset2_Button_Pin);
  buttonState3 =digitalRead(Preset3_Button_Pin);
  buttonState4 =digitalRead(Preset4_Button_Pin);
  buttonState5 =digitalRead(Preset5_Button_Pin);
  buttonState6 =digitalRead(Preset6_Button_Pin);
  buttonState7 =digitalRead(Preset7_Button_Pin);
  buttonState8 =digitalRead(Preset8_Button_Pin);
  buttonStateA =digitalRead(Mode_ButtonA_Pin);
  buttonStateB =digitalRead(Mode_ButtonB_Pin);
 
  if(buttonState1 == LOW || buttonState2 == LOW || buttonState3 == LOW || buttonState4 == LOW || buttonState5 == LOW || buttonState6 == LOW || buttonState7 == LOW || buttonState8 == LOW){
    delay(100);
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
  }
 
  if(buttonState1==LOW && buttonState8==LOW){goto programmer;}
  if(buttonState7==LOW && buttonState8==LOW){goto bankup;}
  if(buttonState1==LOW && buttonState2==LOW){goto bankdown;}
  if(buttonState1==LOW){current_patch = 1;changed=1;};
  if(buttonState2==LOW){current_patch = 2;changed=1;};
  if(buttonState3==LOW){current_patch = 3;changed=1;};
  if(buttonState4==LOW){current_patch = 4;changed=1;};
  if(buttonState5==LOW){current_patch = 5;changed=1;};
  if(buttonState6==LOW){current_patch = 6;changed=1;};
  if(buttonState7==LOW){current_patch = 7;changed=1;};
  if(buttonState8==LOW){current_patch = 8;changed=1;};

   
  if(changed==1){
  //LED STATUS============================================================
    //bank up
restart:   
  //Normal Mode -----------------------------------------------------------------------
  if (buttonStateA==HIGH && buttonStateB==HIGH){
  if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
 
  //recall from memory
  array[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  array[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  array[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  array[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  array[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  array[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  array[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  array[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  array[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  array[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));
  }
 
  //Pedal Mode -----------------------------------------------------------------------
  if (buttonStateA==LOW && buttonStateB==HIGH){
  if(current_patch==1){
    if(array[3]==1){array[3]=0; digitalWrite(Preset1_LED_Pin, LOW); }
    else {array[3]=1; digitalWrite(Preset1_LED_Pin, HIGH);}}
 
  if(current_patch==2){
    if(array[4]==1){array[4]=0; digitalWrite(Preset2_LED_Pin, LOW); }
    else {array[4]=1; digitalWrite(Preset2_LED_Pin, HIGH);}}
 
  if(current_patch==3){
    if(array[5]==1){array[5]=0; digitalWrite(Preset3_LED_Pin, LOW); }
    else {array[5]=1; digitalWrite(Preset3_LED_Pin, HIGH);}}
 
  if(current_patch==4){
    if(array[6]==1){array[6]=0; digitalWrite(Preset4_LED_Pin, LOW); }
    else {array[6]=1; digitalWrite(Preset4_LED_Pin, HIGH);}}
 
  if(current_patch==5){
    if(array[7]==1){array[7]=0; digitalWrite(Preset5_LED_Pin, LOW); }
    else {array[7]=1; digitalWrite(Preset5_LED_Pin, HIGH);}}
 
  if(current_patch==6){
    if(array[8]==1){array[8]=0; array[1] = 0; }
    else {array[8]=1; array[1] = 1;}}
 
  if(current_patch==7){
    if(array[9]==1){array[9]=0; array[2] = 0; }
    else {array[9]=1; array[2] = 1;}}
 
  if(current_patch==8){
    if(array[10]==1){array[10]=0; digitalWrite(Preset8_LED_Pin, LOW); }
    else {array[10]=1; digitalWrite(Preset8_LED_Pin, HIGH);}}
   
  array[11]=0;
  array[12]=0;
  }
   
  //Override Mode -----------------------------------------------------------------------
  if (buttonStateA==HIGH && buttonStateB==LOW){
  if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
 
  //recall from memory
  temparray[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  temparray[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  temparray[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  temparray[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  temparray[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  temparray[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  temparray[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  temparray[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  temparray[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  temparray[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));
   if(temparray[3]==1 && array[3]==1){array[3]=0;}
     else {
       if(temparray[3]==1 || array[3]==1){array[3]=1;}
         else{array[3]=0;}}
   if(temparray[4]==1 && array[4]==1){array[4]=0;}
     else {
       if(temparray[4]==1 || array[4]==1){array[4]=1;}
         else{array[4]=0;}}
   if(temparray[5]==1 && array[5]==1){array[5]=0;}
     else {
       if(temparray[5]==1 || array[5]==1){array[5]=1;}
         else{array[5]=0;}}
   if(temparray[6]==1 && array[6]==1){array[6]=0;}
     else {
       if(temparray[6]==1 || array[6]==1){array[6]=1;}
         else{array[6]=0;}}
   if(temparray[7]==1 && array[7]==1){array[7]=0;}
     else {
       if(temparray[7]==1 || array[7]==1){array[7]=1;}
         else{array[7]=0;}}
   if(temparray[8]==1 && array[8]==1){array[8]=0;}
     else {
       if(temparray[8]==1 || array[8]==1){array[8]=1;}
         else{array[8]=0;}}
   if(temparray[9]==1 && array[9]==1){array[9]=0;}
     else {
       if(temparray[9]==1 || array[9]==1){array[9]=1;}
         else{array[9]=0;}}
   if(temparray[10]==1 && array[10]==1){array[10]=0;}
     else {
       if(temparray[10]==1 || array[10]==1){array[10]=1;}
         else{array[10]=0;}}
   if(temparray[11]==1 && array[11]==1){array[11]=0;}
     else {
       if(temparray[11]==1 || array[11]==1){array[11]=1;}
         else{array[11]=0;}}
   if(temparray[12]==1 && array[12]==1){array[12]=0;}
     else {
       if(temparray[12]==1 || array[12]==1){array[12]=1;}
         else{array[12]=0;}}
}
 
transmit:
  if(current_bank==1) {array[13]=1; array[14]=0; array[15]=0;}
  if(current_bank==2) {array[13]=0; array[14]=1; array[15]=0;}
  if(current_bank==3) {array[13]=0; array[14]=0; array[15]=1;}
  if(current_bank==4) {array[13]=1; array[14]=1; array[15]=0;}

   //bitbang out
    shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
         
    delay(50);
  }//end of changed
goto start; 
 
bankup:
current_bank=current_bank+1;
if(current_bank>=5){current_bank=1;};
//delay(200);
goto transmit;

bankdown:
current_bank=current_bank-1;
if(current_bank<=0){current_bank=4;};
//delay(200);
goto transmit;
 
programmer: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//displayprogram mode
digitalWrite(Preset1_LED_Pin, HIGH);
digitalWrite(Preset2_LED_Pin, HIGH);
digitalWrite(Preset3_LED_Pin, HIGH);
digitalWrite(Preset4_LED_Pin, HIGH);
digitalWrite(Preset5_LED_Pin, HIGH);
array[1] = 1;
array[2] = 1;
digitalWrite(Preset8_LED_Pin, HIGH);
array[3]= 0;
array[4]= 0;
array[5]= 0;
array[6]= 0;
array[7]= 0;
array[8]= 0;
array[9]= 0;
array[10]= 0;
array[11]= 0;
array[12]= 0;
   
//shift out status   
shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
delay(1000);
int z=0;
while(z<=1){
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1==LOW){current_patch = 1;z=5;};
  if(buttonState2==LOW){current_patch = 2;z=5;};
  if(buttonState3==LOW){current_patch = 3;z=5;};
  if(buttonState4==LOW){current_patch = 4;z=5;};
  if(buttonState5==LOW){current_patch = 5;z=5;};
  if(buttonState6==LOW){current_patch = 6;z=5;};
  if(buttonState7==LOW){current_patch = 7;z=5;};
  if(buttonState8==LOW){current_patch = 8;z=5;};
  }
  array[13]= 1;
  array[14]= 1;
  array[15]= 1;
    if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
   
  array[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  array[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  array[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  array[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  array[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  array[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  array[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  array[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  array[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  array[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));

  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
delay(300);

int y=0;
int half=1;
digitalWrite(Preset1_LED_Pin, HIGH);
digitalWrite(Preset2_LED_Pin, HIGH);
digitalWrite(Preset3_LED_Pin, HIGH);
digitalWrite(Preset4_LED_Pin, HIGH);
while(y<=1){
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1==LOW && half==1){
  if(array[3]==1){array[3]=0;}
  else{array[3]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState1==LOW && half==2){
  if(array[8]==1){array[8]=0;}
  else{array[8]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }

  if(buttonState2==LOW && half==1){
  if(array[4]==1){array[4]=0;}
  else{array[4]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState2==LOW && half==2){
  if(array[9]==1){array[9]=0;}
  else{array[9]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState3==LOW && half==1){
  if(array[5]==1){array[5]=0;}
  else{array[5]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState3==LOW && half==2){
  if(array[10]==1){array[10]=0;}
  else{array[10]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }

  if(buttonState4==LOW && half==1){
  if(array[6]==1){array[6]=0;}
  else{array[6]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState4==LOW && half==2){
  if(array[11]==1){array[11]=0;}
  else{array[11]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState5==LOW && half==1){
  if(array[7]==1){array[7]=0;}
  else{array[7]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState5==LOW && half==2){
  if(array[12]==1){array[12]=0;}
  else{array[12]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState8==LOW){
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+0),array[3]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+1),array[4]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+2),array[5]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+3),array[6]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+4),array[7]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+5),array[8]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+6),array[9]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+7),array[10]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+8),array[11]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+9),array[12]);
  y=5;
  digitalWrite(Preset1_LED_Pin, HIGH);
  digitalWrite(Preset2_LED_Pin, HIGH);
  digitalWrite(Preset3_LED_Pin, HIGH);
  digitalWrite(Preset4_LED_Pin, HIGH);
  digitalWrite(Preset5_LED_Pin, HIGH);
  array[1] = 1;
  array[2] = 1;
  digitalWrite(Preset8_LED_Pin, HIGH);
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(1000);
  goto restart;
  }
 
  if(buttonState6==LOW){
  if(half==1){
  half=2;
  digitalWrite(Preset1_LED_Pin, LOW);
  digitalWrite(Preset2_LED_Pin, LOW);
  digitalWrite(Preset3_LED_Pin, LOW);
  digitalWrite(Preset4_LED_Pin, LOW);
  digitalWrite(Preset5_LED_Pin, HIGH);
  array[1] = 1;
  array[2] = 1;
  digitalWrite(Preset8_LED_Pin, HIGH);
  //shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  }
  else{half=1;
  digitalWrite(Preset1_LED_Pin, HIGH);
  digitalWrite(Preset2_LED_Pin, HIGH);
  digitalWrite(Preset3_LED_Pin, HIGH);
  digitalWrite(Preset4_LED_Pin, HIGH);
  digitalWrite(Preset5_LED_Pin, LOW);
  array[1] = 0;
  array[2] = 0;
  digitalWrite(Preset8_LED_Pin, LOW);
  //shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  }
   
   
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }



 delay(1000);
 goto start;
 

}
//end main loop-------------------------------------------------------------------------------------------------------------------------------------------------------------------------




void shiftout(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n,  int o){
int shiftoutarray[16]={0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o};
   for(int i=1; i<17; i++){
      if(shiftoutarray[i]==1){
        digitalWrite(Shift_Bit_Pin, HIGH);
      }
      else {
        digitalWrite(Shift_Bit_Pin, LOW);
     }
     digitalWrite(Shift_Slide_Pin, HIGH);
      delay(1);
      digitalWrite(Shift_Slide_Pin, LOW);
      delay(1);
   }
}



Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Tue Dec 17, 2013 6:52 pm 
Offline
User avatar

Joined: Thu Jan 03, 2008 12:42 pm
Posts: 2501
Slave Chip:

Code:
const int Preset6_LED_Pin = 3;
const int Preset7_LED_Pin = 4;
const int Work_LED_Pin = 5;
const int BankA_LED_Pin = 6;
const int BankB_LED_Pin = 7;
const int BankC_LED_Pin = 8;
const int Loop1_Pin = A5;
const int Loop2_Pin = A4;
const int Loop3_Pin = A3;
const int Loop4_Pin = A2;
const int Loop5_Pin = A1;
const int Loop6_Pin = A0;
const int Loop7_Pin = 13;
const int Loop8_Pin = 12;
const int Loop9_Pin = 11;
const int Loop10_Pin = 10;
const int Shift_Enable_Pin = 2;
const int Shift_Slide_Pin = 1;
const int Shift_Bit_Pin = 0;
//int array[15] = {P6, P7, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, B1, B2, B3};
int array[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int Shift_Enable_Pin_state = LOW;
int Shift_Slide_Pin_state = LOW;
int Shift_Bit_Pin_state = LOW;
int count = 1;

void setup() {               
  pinMode(Loop1_Pin, OUTPUT);     
  pinMode(Loop2_Pin, OUTPUT);
  pinMode(Loop3_Pin, OUTPUT);
  pinMode(Loop4_Pin, OUTPUT);
  pinMode(Loop5_Pin, OUTPUT);
  pinMode(Loop6_Pin, OUTPUT);
  pinMode(Loop7_Pin, OUTPUT);
  pinMode(Loop8_Pin, OUTPUT);
  pinMode(Loop9_Pin, OUTPUT);
  pinMode(Loop10_Pin, OUTPUT);
  pinMode(Preset6_LED_Pin, OUTPUT);
  pinMode(Preset7_LED_Pin, OUTPUT);
  pinMode(Work_LED_Pin, OUTPUT);
  pinMode(BankA_LED_Pin, OUTPUT);
  pinMode(BankB_LED_Pin, OUTPUT);
  pinMode(BankC_LED_Pin, OUTPUT);
  pinMode(Shift_Enable_Pin, INPUT);
  pinMode(Shift_Slide_Pin, INPUT);
  pinMode(Shift_Bit_Pin, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  Shift_Slide_Pin_state = digitalRead(Shift_Slide_Pin);
    if(Shift_Slide_Pin_state==HIGH){
      Shift_Bit_Pin_state = digitalRead(Shift_Bit_Pin);
        if(Shift_Bit_Pin_state==HIGH){
          array[count]=1;
        }
        else {
          array[count]=0;
        }
       count=count + 1 ;
       if(count==17){
         count=1;
       }
       delay(1.5);
    }

if(array[1]==1){digitalWrite(Preset6_LED_Pin, HIGH);} else{digitalWrite(Preset6_LED_Pin, LOW);}
if(array[2]==1){digitalWrite(Preset7_LED_Pin, HIGH);} else{digitalWrite(Preset7_LED_Pin, LOW);}
if(array[3]==1){digitalWrite(Loop1_Pin, HIGH);} else{digitalWrite(Loop1_Pin, LOW);}
if(array[4]==1){digitalWrite(Loop2_Pin, HIGH);} else{digitalWrite(Loop2_Pin, LOW);}
if(array[5]==1){digitalWrite(Loop3_Pin, HIGH);} else{digitalWrite(Loop3_Pin, LOW);}
if(array[6]==1){digitalWrite(Loop4_Pin, HIGH);} else{digitalWrite(Loop4_Pin, LOW);}
if(array[7]==1){digitalWrite(Loop5_Pin, HIGH);} else{digitalWrite(Loop5_Pin, LOW);}
if(array[8]==1){digitalWrite(Loop6_Pin, HIGH);} else{digitalWrite(Loop6_Pin, LOW);}
if(array[9]==1){digitalWrite(Loop7_Pin, HIGH);} else{digitalWrite(Loop7_Pin, LOW);}
if(array[10]==1){digitalWrite(Loop8_Pin, HIGH);} else{digitalWrite(Loop8_Pin, LOW);}
if(array[11]==1){digitalWrite(Loop9_Pin, HIGH);} else{digitalWrite(Loop9_Pin, LOW);}
if(array[12]==1){digitalWrite(Loop10_Pin, HIGH);} else{digitalWrite(Loop10_Pin, LOW);}
if(array[13]==1){digitalWrite(BankA_LED_Pin, HIGH);} else{digitalWrite(BankA_LED_Pin, LOW);}
if(array[14]==1){digitalWrite(BankB_LED_Pin, HIGH);} else{digitalWrite(BankB_LED_Pin, LOW);}
if(array[15]==1){digitalWrite(BankC_LED_Pin, HIGH);} else{digitalWrite(BankC_LED_Pin, LOW);}
}


Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Sat Dec 28, 2013 4:08 pm 
Offline

Joined: Fri Oct 16, 2009 9:32 pm
Posts: 1397
Location: Smithers, British Columbia Canada
Got my aurduino uno finally
is there a tutorial on how to do this?
I can't find anything on programming ic's
do I use a bread board and jumper all the pins to the ic on a bread board and run the code?

_________________
Doh! Stupid Diode


Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Sat Dec 28, 2013 8:12 pm 
Offline
Moderator
User avatar

Joined: Mon Feb 04, 2013 8:28 pm
Posts: 1353
Location: Richland, WA.
RiffRaff wrote:
Got my aurduino uno finally
is there a tutorial on how to do this?
I can't find anything on programming ic's
do I use a bread board and jumper all the pins to the ic on a bread board and run the code?



I'm not sure what chip is used, but if it's attiny, this might help:
http://instructables.com/id/Program-an- ... h-Arduino/

This might help with a better grasp of the tech:
http://analog.com/mt/www.analog.com/en/ ... p/fca.html

_________________
The tone is in my hands?!
Email: nick@buildyourownclone.com


Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Sat Dec 28, 2013 10:42 pm 
Offline

Joined: Fri Oct 16, 2009 9:32 pm
Posts: 1397
Location: Smithers, British Columbia Canada
Nwkenning wrote:
RiffRaff wrote:
Got my aurduino uno finally
is there a tutorial on how to do this?
I can't find anything on programming ic's
do I use a bread board and jumper all the pins to the ic on a bread board and run the code?



I'm not sure what chip is used, but if it's attiny, this might help:
http://instructables.com/id/Program-an- ... h-Arduino/

This might help with a better grasp of the tech:
http://analog.com/mt/www.analog.com/en/ ... p/fca.html


Thanks for the links I will look into them
Found this pic. would this be the way to hook it up?

_________________
Doh! Stupid Diode


Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Thu Jan 02, 2014 11:08 am 
Offline
Moderator
User avatar

Joined: Mon Feb 04, 2013 8:28 pm
Posts: 1353
Location: Richland, WA.
RiffRaff wrote:
Nwkenning wrote:
RiffRaff wrote:
Got my aurduino uno finally
is there a tutorial on how to do this?
I can't find anything on programming ic's
do I use a bread board and jumper all the pins to the ic on a bread board and run the code?



I'm not sure what chip is used, but if it's attiny, this might help:
http://instructables.com/id/Program-an- ... h-Arduino/

This might help with a better grasp of the tech:
http://analog.com/mt/www.analog.com/en/ ... p/fca.html


Thanks for the links I will look into them
Found this pic. would this be the way to hook it up?


it depends on the actual chip used. if that ATMega is what is used in the effectblade, then probably.

_________________
The tone is in my hands?!
Email: nick@buildyourownclone.com


Top
 Profile  
 
 Post subject: Re: Effectblade Code
PostPosted: Tue Mar 18, 2014 1:38 pm 
Offline
Moderator
User avatar

Joined: Wed Apr 26, 2006 5:14 pm
Posts: 8586
Location: Truckee, CA
Re-posting this just so it stays permanent.

Main Chip Version 2 (current):

Code:
#include <EEPROM.h>

//pin assigments
const int Preset1_LED_Pin = 0;
const int Preset2_LED_Pin = 1;
const int Preset3_LED_Pin = 2;
const int Preset4_LED_Pin = 3;
const int Preset5_LED_Pin = 4;
const int Preset8_LED_Pin = 9;
const int Preset1_Button_Pin = A5;
const int Preset2_Button_Pin = A4;
const int Preset3_Button_Pin = A3;
const int Preset4_Button_Pin = A2;
const int Preset5_Button_Pin = A1;
const int Preset6_Button_Pin = A0;
const int Preset7_Button_Pin = 13;
const int Preset8_Button_Pin = 12;
const int Mode_ButtonA_Pin = 11;
const int Mode_ButtonB_Pin = 10;
const int Shift_Enable_Pin = 6;
const int Shift_Slide_Pin = 7;
const int Shift_Bit_Pin = 8;

int buttonState1 = HIGH;         // variable for reading the pushbutton status
int buttonState2 = HIGH;
int buttonState3 = HIGH;
int buttonState4 = HIGH;
int buttonState5 = HIGH;
int buttonState6 = HIGH;
int buttonState7 = HIGH;
int buttonState8 = HIGH;
int buttonStateA = HIGH;
int buttonStateB = HIGH;
int current_bank = 1;
int current_patch = 1;
//int array[15] = {P6, P7, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, B1, B2, B3};
int array[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};
int temparray[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0};

void setup() {
  pinMode(Preset1_LED_Pin, OUTPUT);   
  pinMode(Preset2_LED_Pin, OUTPUT);   
  pinMode(Preset3_LED_Pin, OUTPUT);   
  pinMode(Preset4_LED_Pin, OUTPUT); 
  pinMode(Preset5_LED_Pin, OUTPUT);   
  pinMode(Preset8_LED_Pin, OUTPUT);   
  pinMode(Preset1_Button_Pin, INPUT_PULLUP);
  pinMode(Preset2_Button_Pin, INPUT_PULLUP);
  pinMode(Preset3_Button_Pin, INPUT_PULLUP);
  pinMode(Preset4_Button_Pin, INPUT_PULLUP);
  pinMode(Preset5_Button_Pin, INPUT_PULLUP);
  pinMode(Preset6_Button_Pin, INPUT_PULLUP);
  pinMode(Preset7_Button_Pin, INPUT_PULLUP);
  pinMode(Preset8_Button_Pin, INPUT_PULLUP);
  pinMode(Mode_ButtonA_Pin, INPUT_PULLUP);
  pinMode(Mode_ButtonB_Pin, INPUT_PULLUP);
  pinMode(Shift_Enable_Pin, OUTPUT);   
  pinMode(Shift_Slide_Pin, OUTPUT);   
  pinMode(Shift_Bit_Pin, OUTPUT);
 }
 
 void loop(){
start:
  int changed = 0;
  buttonState1 =digitalRead(Preset1_Button_Pin);
  buttonState2 =digitalRead(Preset2_Button_Pin);
  buttonState3 =digitalRead(Preset3_Button_Pin);
  buttonState4 =digitalRead(Preset4_Button_Pin);
  buttonState5 =digitalRead(Preset5_Button_Pin);
  buttonState6 =digitalRead(Preset6_Button_Pin);
  buttonState7 =digitalRead(Preset7_Button_Pin);
  buttonState8 =digitalRead(Preset8_Button_Pin);
  buttonStateA =digitalRead(Mode_ButtonA_Pin);
  buttonStateB =digitalRead(Mode_ButtonB_Pin);
 
  if(buttonState1 == LOW || buttonState2 == LOW || buttonState3 == LOW || buttonState4 == LOW || buttonState5 == LOW || buttonState6 == LOW || buttonState7 == LOW || buttonState8 == LOW){
    delay(100);
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
  }
 
  if(buttonState1==LOW && buttonState8==LOW){goto programmer;}
  if(buttonState7==LOW && buttonState8==LOW){goto bankup;}
  if(buttonState1==LOW && buttonState2==LOW){goto bankdown;}
  if(buttonState1==LOW){current_patch = 1;changed=1;};
  if(buttonState2==LOW){current_patch = 2;changed=1;};
  if(buttonState3==LOW){current_patch = 3;changed=1;};
  if(buttonState4==LOW){current_patch = 4;changed=1;};
  if(buttonState5==LOW){current_patch = 5;changed=1;};
  if(buttonState6==LOW){current_patch = 6;changed=1;};
  if(buttonState7==LOW){current_patch = 7;changed=1;};
  if(buttonState8==LOW){current_patch = 8;changed=1;};

   
  if(changed==1){
  //LED STATUS============================================================
    //bank up
restart:   
  //Normal Mode -----------------------------------------------------------------------
  if (buttonStateA==HIGH && buttonStateB==HIGH){
  if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
 
  //recall from memory
  array[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  array[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  array[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  array[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  array[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  array[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  array[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  array[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  array[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  array[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));
  }
 
  //Pedal Mode -----------------------------------------------------------------------
  if (buttonStateA==LOW && buttonStateB==HIGH){
  if(current_patch==1){
    if(array[3]==1){array[3]=0; digitalWrite(Preset1_LED_Pin, LOW); }
    else {array[3]=1; digitalWrite(Preset1_LED_Pin, HIGH);}}
 
  if(current_patch==2){
    if(array[4]==1){array[4]=0; digitalWrite(Preset2_LED_Pin, LOW); }
    else {array[4]=1; digitalWrite(Preset2_LED_Pin, HIGH);}}
 
  if(current_patch==3){
    if(array[5]==1){array[5]=0; digitalWrite(Preset3_LED_Pin, LOW); }
    else {array[5]=1; digitalWrite(Preset3_LED_Pin, HIGH);}}
 
  if(current_patch==4){
    if(array[6]==1){array[6]=0; digitalWrite(Preset4_LED_Pin, LOW); }
    else {array[6]=1; digitalWrite(Preset4_LED_Pin, HIGH);}}
 
  if(current_patch==5){
    if(array[7]==1){array[7]=0; digitalWrite(Preset5_LED_Pin, LOW); }
    else {array[7]=1; digitalWrite(Preset5_LED_Pin, HIGH);}}
 
  if(current_patch==6){
    if(array[8]==1){array[8]=0; array[1] = 0; }
    else {array[8]=1; array[1] = 1;}}
 
  if(current_patch==7){
    if(array[9]==1){array[9]=0; array[2] = 0; }
    else {array[9]=1; array[2] = 1;}}
 
  if(current_patch==8){
    if(array[10]==1){array[10]=0; digitalWrite(Preset8_LED_Pin, LOW); }
    else {array[10]=1; digitalWrite(Preset8_LED_Pin, HIGH);}}
   
  array[11]=0;
  array[12]=0;
  }
   
  //Override Mode -----------------------------------------------------------------------
  if (buttonStateA==HIGH && buttonStateB==LOW){
  if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
 
  //recall from memory
  temparray[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  temparray[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  temparray[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  temparray[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  temparray[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  temparray[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  temparray[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  temparray[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  temparray[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  temparray[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));
   if(temparray[3]==1 && array[3]==1){array[3]=0;}
     else {
       if(temparray[3]==1 || array[3]==1){array[3]=1;}
         else{array[3]=0;}}
   if(temparray[4]==1 && array[4]==1){array[4]=0;}
     else {
       if(temparray[4]==1 || array[4]==1){array[4]=1;}
         else{array[4]=0;}}
   if(temparray[5]==1 && array[5]==1){array[5]=0;}
     else {
       if(temparray[5]==1 || array[5]==1){array[5]=1;}
         else{array[5]=0;}}
   if(temparray[6]==1 && array[6]==1){array[6]=0;}
     else {
       if(temparray[6]==1 || array[6]==1){array[6]=1;}
         else{array[6]=0;}}
   if(temparray[7]==1 && array[7]==1){array[7]=0;}
     else {
       if(temparray[7]==1 || array[7]==1){array[7]=1;}
         else{array[7]=0;}}
   if(temparray[8]==1 && array[8]==1){array[8]=0;}
     else {
       if(temparray[8]==1 || array[8]==1){array[8]=1;}
         else{array[8]=0;}}
   if(temparray[9]==1 && array[9]==1){array[9]=0;}
     else {
       if(temparray[9]==1 || array[9]==1){array[9]=1;}
         else{array[9]=0;}}
   if(temparray[10]==1 && array[10]==1){array[10]=0;}
     else {
       if(temparray[10]==1 || array[10]==1){array[10]=1;}
         else{array[10]=0;}}
   if(temparray[11]==1 && array[11]==1){array[11]=0;}
     else {
       if(temparray[11]==1 || array[11]==1){array[11]=1;}
         else{array[11]=0;}}
   if(temparray[12]==1 && array[12]==1){array[12]=0;}
     else {
       if(temparray[12]==1 || array[12]==1){array[12]=1;}
         else{array[12]=0;}}
}
 
transmit:
  if(current_bank==1) {array[13]=1; array[14]=0; array[15]=0;}
  if(current_bank==2) {array[13]=0; array[14]=1; array[15]=0;}
  if(current_bank==3) {array[13]=0; array[14]=0; array[15]=1;}
  if(current_bank==4) {array[13]=1; array[14]=1; array[15]=0;}

   //bitbang out
    shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
         
    delay(50);
  }//end of changed
goto start; 
 
bankup:
current_bank=current_bank+1;
if(current_bank>=5){current_bank=1;};
//delay(200);
goto transmit;

bankdown:
current_bank=current_bank-1;
if(current_bank<=0){current_bank=4;};
//delay(200);
goto transmit;
 
programmer: //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//displayprogram mode
digitalWrite(Preset1_LED_Pin, HIGH);
digitalWrite(Preset2_LED_Pin, HIGH);
digitalWrite(Preset3_LED_Pin, HIGH);
digitalWrite(Preset4_LED_Pin, HIGH);
digitalWrite(Preset5_LED_Pin, HIGH);
array[1] = 1;
array[2] = 1;
digitalWrite(Preset8_LED_Pin, HIGH);
array[3]= 0;
array[4]= 0;
array[5]= 0;
array[6]= 0;
array[7]= 0;
array[8]= 0;
array[9]= 0;
array[10]= 0;
array[11]= 0;
array[12]= 0;
   
//shift out status   
shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
delay(1000);
int z=0;
while(z<=1){
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1==LOW){current_patch = 1;z=5;};
  if(buttonState2==LOW){current_patch = 2;z=5;};
  if(buttonState3==LOW){current_patch = 3;z=5;};
  if(buttonState4==LOW){current_patch = 4;z=5;};
  if(buttonState5==LOW){current_patch = 5;z=5;};
  if(buttonState6==LOW){current_patch = 6;z=5;};
  if(buttonState7==LOW){current_patch = 7;z=5;};
  if(buttonState8==LOW){current_patch = 8;z=5;};
  }
  array[13]= 1;
  array[14]= 1;
  array[15]= 1;
    if(current_patch==1){digitalWrite(Preset1_LED_Pin, HIGH); }
  else {digitalWrite(Preset1_LED_Pin, LOW);}
 
  if(current_patch==2){digitalWrite(Preset2_LED_Pin, HIGH);}
  else {digitalWrite(Preset2_LED_Pin, LOW);}
 
  if(current_patch==3){digitalWrite(Preset3_LED_Pin, HIGH);}
  else {digitalWrite(Preset3_LED_Pin, LOW);}
 
  if(current_patch==4){digitalWrite(Preset4_LED_Pin, HIGH);}
  else {digitalWrite(Preset4_LED_Pin, LOW);}
 
  if(current_patch==5){digitalWrite(Preset5_LED_Pin, HIGH);}
  else {digitalWrite(Preset5_LED_Pin, LOW);}
 
  if(current_patch==6){array[1] = 1;}
  else {array[1] = 0;}
 
  if(current_patch==7){array[2] = 1;}
  else {array[2] = 0;}
 
  if(current_patch==8){digitalWrite(Preset8_LED_Pin, HIGH);}
  else {digitalWrite(Preset8_LED_Pin, LOW);}
   
  array[3]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+0));
  array[4]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+1));
  array[5]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+2));
  array[6]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+3));
  array[7]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+4));
  array[8]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+5));
  array[9]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+6));
  array[10]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+7));
  array[11]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+8));
  array[12]= EEPROM.read((((current_patch-1)*10)+(current_bank*100)+9));

  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
delay(300);

int y=0;
int half=1;
digitalWrite(Preset1_LED_Pin, HIGH);
digitalWrite(Preset2_LED_Pin, HIGH);
digitalWrite(Preset3_LED_Pin, HIGH);
digitalWrite(Preset4_LED_Pin, HIGH);
while(y<=1){
    buttonState1 =digitalRead(Preset1_Button_Pin);
    buttonState2 =digitalRead(Preset2_Button_Pin);
    buttonState3 =digitalRead(Preset3_Button_Pin);
    buttonState4 =digitalRead(Preset4_Button_Pin);
    buttonState5 =digitalRead(Preset5_Button_Pin);
    buttonState6 =digitalRead(Preset6_Button_Pin);
    buttonState7 =digitalRead(Preset7_Button_Pin);
    buttonState8 =digitalRead(Preset8_Button_Pin);
 
  if(buttonState1==LOW && half==1){
  if(array[3]==1){array[3]=0;}
  else{array[3]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState1==LOW && half==2){
  if(array[8]==1){array[8]=0;}
  else{array[8]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }

  if(buttonState2==LOW && half==1){
  if(array[4]==1){array[4]=0;}
  else{array[4]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState2==LOW && half==2){
  if(array[9]==1){array[9]=0;}
  else{array[9]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState3==LOW && half==1){
  if(array[5]==1){array[5]=0;}
  else{array[5]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState3==LOW && half==2){
  if(array[10]==1){array[10]=0;}
  else{array[10]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }

  if(buttonState4==LOW && half==1){
  if(array[6]==1){array[6]=0;}
  else{array[6]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState4==LOW && half==2){
  if(array[11]==1){array[11]=0;}
  else{array[11]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState5==LOW && half==1){
  if(array[7]==1){array[7]=0;}
  else{array[7]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState5==LOW && half==2){
  if(array[12]==1){array[12]=0;}
  else{array[12]=1;}
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }
 
  if(buttonState8==LOW){
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+0),array[3]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+1),array[4]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+2),array[5]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+3),array[6]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+4),array[7]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+5),array[8]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+6),array[9]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+7),array[10]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+8),array[11]);
  EEPROM.write((((current_patch-1)*10)+(current_bank*100)+9),array[12]);
  y=5;
  digitalWrite(Preset1_LED_Pin, HIGH);
  digitalWrite(Preset2_LED_Pin, HIGH);
  digitalWrite(Preset3_LED_Pin, HIGH);
  digitalWrite(Preset4_LED_Pin, HIGH);
  digitalWrite(Preset5_LED_Pin, HIGH);
  array[1] = 1;
  array[2] = 1;
  digitalWrite(Preset8_LED_Pin, HIGH);
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(1000);
  goto restart;
  }
 
  if(buttonState6==LOW){
  if(half==1){
  half=2;
  digitalWrite(Preset1_LED_Pin, LOW);
  digitalWrite(Preset2_LED_Pin, LOW);
  digitalWrite(Preset3_LED_Pin, LOW);
  digitalWrite(Preset4_LED_Pin, LOW);
  digitalWrite(Preset5_LED_Pin, HIGH);
  array[1] = 1;
  array[2] = 1;
  digitalWrite(Preset8_LED_Pin, HIGH);
  //shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  }
  else{half=1;
  digitalWrite(Preset1_LED_Pin, HIGH);
  digitalWrite(Preset2_LED_Pin, HIGH);
  digitalWrite(Preset3_LED_Pin, HIGH);
  digitalWrite(Preset4_LED_Pin, HIGH);
  digitalWrite(Preset5_LED_Pin, LOW);
  array[1] = 0;
  array[2] = 0;
  digitalWrite(Preset8_LED_Pin, LOW);
  //shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  }
   
   
  shiftout(array[1],array[2],array[3],array[4],array[5],array[6],array[7],array[8],array[9],array[10],array[11],array[12],array[13],array[14],array[15] );
  delay(300); 
  }



 delay(1000);
 goto start;
 

}
//end main loop-------------------------------------------------------------------------------------------------------------------------------------------------------------------------




void shiftout(int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l, int m, int n,  int o){
int shiftoutarray[16]={0,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o};
   for(int i=1; i<17; i++){
      if(shiftoutarray[i]==1){
        digitalWrite(Shift_Bit_Pin, HIGH);
      }
      else {
        digitalWrite(Shift_Bit_Pin, LOW);
     }
     digitalWrite(Shift_Slide_Pin, HIGH);
      delay(1);
      digitalWrite(Shift_Slide_Pin, LOW);
      delay(1);
   }
}



Slave Chip:

Code:
const int Preset6_LED_Pin = 3;
const int Preset7_LED_Pin = 4;
const int Work_LED_Pin = 5;
const int BankA_LED_Pin = 6;
const int BankB_LED_Pin = 7;
const int BankC_LED_Pin = 8;
const int Loop1_Pin = A5;
const int Loop2_Pin = A4;
const int Loop3_Pin = A3;
const int Loop4_Pin = A2;
const int Loop5_Pin = A1;
const int Loop6_Pin = A0;
const int Loop7_Pin = 13;
const int Loop8_Pin = 12;
const int Loop9_Pin = 11;
const int Loop10_Pin = 10;
const int Shift_Enable_Pin = 2;
const int Shift_Slide_Pin = 1;
const int Shift_Bit_Pin = 0;
//int array[15] = {P6, P7, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, B1, B2, B3};
int array[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int Shift_Enable_Pin_state = LOW;
int Shift_Slide_Pin_state = LOW;
int Shift_Bit_Pin_state = LOW;
int count = 1;

void setup() {               
  pinMode(Loop1_Pin, OUTPUT);     
  pinMode(Loop2_Pin, OUTPUT);
  pinMode(Loop3_Pin, OUTPUT);
  pinMode(Loop4_Pin, OUTPUT);
  pinMode(Loop5_Pin, OUTPUT);
  pinMode(Loop6_Pin, OUTPUT);
  pinMode(Loop7_Pin, OUTPUT);
  pinMode(Loop8_Pin, OUTPUT);
  pinMode(Loop9_Pin, OUTPUT);
  pinMode(Loop10_Pin, OUTPUT);
  pinMode(Preset6_LED_Pin, OUTPUT);
  pinMode(Preset7_LED_Pin, OUTPUT);
  pinMode(Work_LED_Pin, OUTPUT);
  pinMode(BankA_LED_Pin, OUTPUT);
  pinMode(BankB_LED_Pin, OUTPUT);
  pinMode(BankC_LED_Pin, OUTPUT);
  pinMode(Shift_Enable_Pin, INPUT);
  pinMode(Shift_Slide_Pin, INPUT);
  pinMode(Shift_Bit_Pin, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  Shift_Slide_Pin_state = digitalRead(Shift_Slide_Pin);
    if(Shift_Slide_Pin_state==HIGH){
      Shift_Bit_Pin_state = digitalRead(Shift_Bit_Pin);
        if(Shift_Bit_Pin_state==HIGH){
          array[count]=1;
        }
        else {
          array[count]=0;
        }
       count=count + 1 ;
       if(count==17){
         count=1;
       }
       delay(1.5);
    }

if(array[1]==1){digitalWrite(Preset6_LED_Pin, HIGH);} else{digitalWrite(Preset6_LED_Pin, LOW);}
if(array[2]==1){digitalWrite(Preset7_LED_Pin, HIGH);} else{digitalWrite(Preset7_LED_Pin, LOW);}
if(array[3]==1){digitalWrite(Loop1_Pin, HIGH);} else{digitalWrite(Loop1_Pin, LOW);}
if(array[4]==1){digitalWrite(Loop2_Pin, HIGH);} else{digitalWrite(Loop2_Pin, LOW);}
if(array[5]==1){digitalWrite(Loop3_Pin, HIGH);} else{digitalWrite(Loop3_Pin, LOW);}
if(array[6]==1){digitalWrite(Loop4_Pin, HIGH);} else{digitalWrite(Loop4_Pin, LOW);}
if(array[7]==1){digitalWrite(Loop5_Pin, HIGH);} else{digitalWrite(Loop5_Pin, LOW);}
if(array[8]==1){digitalWrite(Loop6_Pin, HIGH);} else{digitalWrite(Loop6_Pin, LOW);}
if(array[9]==1){digitalWrite(Loop7_Pin, HIGH);} else{digitalWrite(Loop7_Pin, LOW);}
if(array[10]==1){digitalWrite(Loop8_Pin, HIGH);} else{digitalWrite(Loop8_Pin, LOW);}
if(array[11]==1){digitalWrite(Loop9_Pin, HIGH);} else{digitalWrite(Loop9_Pin, LOW);}
if(array[12]==1){digitalWrite(Loop10_Pin, HIGH);} else{digitalWrite(Loop10_Pin, LOW);}
if(array[13]==1){digitalWrite(BankA_LED_Pin, HIGH);} else{digitalWrite(BankA_LED_Pin, LOW);}
if(array[14]==1){digitalWrite(BankB_LED_Pin, HIGH);} else{digitalWrite(BankB_LED_Pin, LOW);}
if(array[15]==1){digitalWrite(BankC_LED_Pin, HIGH);} else{digitalWrite(BankC_LED_Pin, LOW);}
}

_________________
MasterDelayer/Reverbrador/Ampaholic/TopJacker


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group