/* ___ ________ ______ _ __ __
/ \ \ / / _ \ \ / / _ \ / \ \ \/ /
/ _ \ \ / /| | | \ V /| |_) | / _ \ \ /
/ ___ \ V / | |_| || | | _ < / ___ \ / \
/_/ \_\_/ |____/ |_| |_| \_\/_/ \_\/_/\_\
*/
#define ena 2
#define enb 3
#define s0a 4
#define s1a 5
#define s2a 6
#define s3a 7
#define s0b 8
#define s1b 9
#define s2b 10
#define s3b 11
#define za 12
#define zb 13
#define t 1
void setup ( ) {
pinMode ( ena, 1 ); digitalWrite ( ena, 0 );
pinMode ( enb, 1 ); digitalWrite ( enb, 0 );
pinMode ( s0a, 1 ); digitalWrite ( s0a, 0 );
pinMode ( s1a, 1 ); digitalWrite ( s1a, 0 );
pinMode ( s2a, 1 ); digitalWrite ( s2a, 0 );
pinMode ( s3a, 1 ); digitalWrite ( s3a, 0 );
pinMode ( s0b, 1 ); digitalWrite ( s0b, 0 );
pinMode ( s1b, 1 ); digitalWrite ( s1b, 0 );
pinMode ( s2b, 1 ); digitalWrite ( s2b, 0 );
pinMode ( s3b, 1 ); digitalWrite ( s3b, 0 );
pinMode ( za, 1 ); digitalWrite ( za, 0 );
pinMode ( zb, 1 ); digitalWrite ( zb, 1 );
Serial.begin(9600);Serial.println("START");
}
void seta(bool a, bool b, bool c, bool d){
digitalWrite ( ena, 1 );
digitalWrite ( enb, 1 );
digitalWrite ( s0a, d );
digitalWrite ( s1a, c );
digitalWrite ( s2a, b );
digitalWrite ( s3a, a );
digitalWrite ( ena, 0 );
}
void setb(bool a, bool b, bool c, bool d){
digitalWrite ( s0b, d );
digitalWrite ( s1b, c );
digitalWrite ( s2b, b );
digitalWrite ( s3b, a );
digitalWrite ( ena, 0 );
digitalWrite ( enb, 0 );
delayMicroseconds(t);
}
void off(){
digitalWrite ( ena, 1 );
digitalWrite ( enb, 1 );
}
void loop ( ) {
vel7();
}
void set(int a, int b){
if(a==1){seta(0,0,0,0);}
if(a==2){seta(0,0,0,1);}
if(a==3){seta(0,0,1,0);}
if(a==4){seta(0,0,1,1);}
if(a==5){seta(0,1,0,0);}
if(a==6){seta(0,1,0,1);}
if(a==7){seta(0,1,1,0);}
if(a==8){seta(0,1,1,1);}
if(a==10){seta(1,0,0,1);}
if(a==11){seta(1,0,1,0);}
if(a==12){seta(1,0,1,1);}
if(a==13){seta(1,1,0,0);}
if(a==14){seta(1,1,0,1);}
if(a==15){seta(1,1,1,0);}
if(a==16){seta(1,1,1,1);}
if(b==1){setb(0,0,0,0);}
if(b==2){setb(0,0,0,1);}
if(b==3){setb(0,0,1,0);}
if(b==4){setb(0,0,1,1);}
if(b==5){setb(0,1,0,0);}
if(b==6){setb(0,1,0,1);}
if(b==7){setb(0,1,1,0);}
if(b==8){setb(0,1,1,1);}
if(b==9){setb(1,0,0,0);}
if(b==10){setb(1,0,0,1);}
if(b==11){setb(1,0,1,0);}
if(b==12){setb(1,0,1,1);}
if(b==13){setb(1,1,0,0);}
if(b==14){setb(1,1,0,1);}
if(b==15){setb(1,1,1,0);}
if(b==16){setb(1,1,1,1);}
}
void test ( ) {
set(1, 1); set(2, 2); set(3, 3); set(4, 4);
set(5, 5); set(6, 6); set(7, 7); set(8, 8);
set(9, 9); set(10, 10); set(11, 11); set(12, 12);
set(13, 13); set(14, 14); set(15, 15); set(16, 16);
for (int i = 15; i <= 0; i--) { set(i, 16); delay ( t ); }
set(2, 15); set(3, 14); set(4, 13); set(5, 12);
set(6, 11); set(7, 10); set(8, 9); set(9, 8);
set(10, 7); set(11, 6); set(12, 5); set(13,4);
set(14, 3); set(15, 2); set(16, 1);
}
void vel7 (){ set( 8, 1 ); set( 9, 1 ); set( 1, 2 ); set( 1, 2 ); set( 1, 2 ); set( 1, 2 ); set( 1, 3 ); set( 1, 3 ); set( 1, 3 ); set( 1, 4 ); set( 1, 4 ); set( 1, 5 ); set( 1, 5 ); set( 1, 5 ); set( 1, 6 ); set( 1, 6 ); set( 1, 6 ); set( 1, 7 ); set( 1, 7 ); set( 1, 7 ); set( 1, 7 ); set( 1, 8 ); set( 1, 8 ); set( 1, 8 ); set( 1, 8 ); set( 1, 9 ); set( 1, 9 ); set( 1, 9 ); set( 1, 10 ); set( 1, 10 ); set( 1, 11 ); set( 1, 11 ); set( 1, 12 ); set( 1, 12 ); set( 1, 13 ); set( 1, 13 ); set( 1, 14 ); set( 1, 14 ); set( 1, 14 ); set( 1, 15 ); set( 1, 15 ); set( 1, 15 ); set( 1, 15 ); set( 1, 16 ); set( 1, 16 ); }