/*
In thhisss project
*/
#define DS 5 // PIN of Arduino connects to PIN 14 74595 data in
#define STCP_B 6 // PIN of Arduino connects to PIN 14 74595 data in
#define SHCP 3 // PIN of Arduino connects to PIN 11 74595 Shift Clock
#define STCP 4 // PIN of Arduino connects to PIN 12 74595 Output Latch
byte tbl_COL [] = {1,1,1,1,1 ,1 ,2,2,2,2, 2,2 ,4,4,4,4,4 ,4 ,8,8,8,8,8 ,8};
byte tbl_ROW [] = {1,2,4,8,16,32,1,2,4,8,16,32,1,2,4,8,16,32,1,2,4,8,16,32};
byte tbl_status [] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
// Macros
#define dy delay(300)
#define num_of_leds sizeof(tbl) / sizeof(int)
;
long currentDelay = 0;
int ref = 0;
int row; // general loop counter
int col;
void sendOutDataA(int value)
{
shiftOut(DS,SHCP,MSBFIRST,value);
digitalWrite(STCP, LOW);
digitalWrite(STCP, HIGH);
digitalWrite(STCP, LOW);
}
void sendOutDataB(int value)
{
shiftOut(DS,SHCP,MSBFIRST,value);
digitalWrite(STCP_B, LOW);
digitalWrite(STCP_B, HIGH);
digitalWrite(STCP_B, LOW);
}
void setup()
{
Serial.begin(57600);
pinMode(SHCP,OUTPUT);
pinMode(STCP,OUTPUT);
pinMode(DS, OUTPUT);
pinMode(STCP_B,OUTPUT);
Serial.println("Binary counter");
randomSeed(A0);
}
void loop()
{
shot(random(0,23) );
delay(50);
/* for(int shot=0;shot<24;shot++){
sendOutDataB( tbl_COL[shot]);
sendOutDataA( tbl_ROW[shot]);
delay(500);
}*/
}
void shot(byte value){
sendOutDataB( tbl_COL[value]);
sendOutDataA( tbl_ROW[value]);
tbl_status[value] = 1;
}
void resetShot(value value){
tbl_status[value] = 0;
}
Row Select
Column Select
1
2
4
8