#include // This mess created by UncleBone: unclebone@gmail.com byte latchPin = 5; // ST_CP of 74HC595 byte clockPin = 4; // SH_CP of 74HC595 byte dataPin[] = {2,6,7,8,9}; byte blade[5][5]; long new_time = 1; long last_time = 1; long timing = 1; volatile int breaker = HIGH; const byte numRegister = 4; //Number of shift regiters on each blade const byte numAngle = 24; //Number of angles in each group const byte numGroup = 5; //Number of groups. each blade is always in a separate group and increments around the circle back to Zero position int RotaionCnt = 0; //counts each full rotation currently for the purpose of switching between whole images byte image = 0; //which whole image. the first definition in the array byte group = 0; //there are 5 groups to separate each fan blade. byte LightStatus[5][4]; //array of 4 separate images containing 5 groups of 12 angles with 4 bytes of data and another 12 with 2 bytes to help fill in the outer portion of the disc (1200 bytes of ram to begin with) PROGMEM prog_uint8_t angleDef[4][5][24][4] = { {{{192,239,255,31},{192,239,255,31},{192,255,255,3},{192,255,255,3},{128,255,127,0},{128,255,127,0},{192,127,192,15},{192,31,192,15},{192,15,135,63},{192,143,135,63},{192,143,31,126},{192,143,31,126},{128,31,63,126},{128,31,63,126},{0,127,0,254},{0,254,0,254},{0,252,7,255},{0,240,7,255},{0,224,255,255},{0,128,255,255},{0,0,252,255},{0,0,252,255},{0,0,128,127},{0,0,128,127}},{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,120,0},{0,0,120,0},{0,0,252,3},{0,0,252,3},{0,240,231,15},{0,224,231,15},{128,143,159,31},{31,63,159,31},{126,126,254,63},{248,253,254,63},{248,249,253,255},{240,251,253,255},{224,247,251,63},{224,247,251,63}}} , {{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,255,0,0}},{{224,255,31,0},{248,255,31,0},{252,255,255,1},{254,255,255,1},{255,255,255,7},{255,255,255,7},{255,135,255,15},{255,1,255,15},{255,130,253,31},{255,103,253,31},{254,27,250,63},{252,7,250,63},{252,15,254,63},{240,255,254,63},{224,255,247,127},{128,255,247,127},{0,254,251,127},{0,112,251,127},{0,0,252,255},{0,0,252,255},{0,0,254,255},{0,0,254,255},{0,128,255,255},{0,192,255,255}},{{0,224,255,127},{0,224,255,127},{0,224,255,127},{0,224,255,127},{0,224,255,31},{0,224,255,31},{0,224,255,3},{0,192,255,3},{0,192,63,0},{0,192,63,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}}} , {{{0,0,255,255},{0,240,255,255},{128,255,255,255},{252,255,255,255},{254,255,255,255},{240,255,255,255},{128,255,255,255},{0,252,255,255},{0,240,255,255},{0,192,255,255},{0,128,255,255},{0,0,255,255},{0,0,252,255},{0,0,252,255},{0,0,240,255},{0,0,240,255},{0,0,192,255},{0,0,192,255},{0,0,0,255},{0,0,0,255},{0,0,0,254},{0,0,0,254},{0,0,0,254},{0,0,0,254}},{{0,0,224,255},{0,0,224,255},{0,248,255,255},{252,255,255,255},{255,255,255,255},{248,255,255,255},{192,255,255,255},{0,254,255,255},{0,248,255,255},{0,192,255,255},{0,128,255,255},{0,0,255,255},{0,0,248,255},{0,0,248,255},{0,0,192,255},{0,0,192,255},{0,0,128,255},{0,0,128,255},{0,0,0,254},{0,0,0,254},{0,0,128,255},{0,0,128,255},{0,0,248,255},{0,128,248,255}},{{0,224,255,255},{192,255,255,255},{255,255,255,255},{255,255,255,255},{248,255,255,255},{128,255,255,255},{0,254,255,255},{0,240,255,255},{0,192,255,255},{0,0,255,255},{0,0,254,255},{0,0,254,255},{0,0,240,255},{0,0,240,255},{0,0,192,255},{0,0,192,255},{0,0,0,255},{0,0,0,255},{0,0,0,254},{0,0,0,254},{0,0,0,248},{0,0,0,248},{0,0,0,248},{0,0,0,248}},{{0,0,0,252},{0,0,0,252},{0,0,240,255},{0,0,240,255},{0,255,255,255},{255,255,255,255},{255,255,255,255},{252,255,255,255},{224,255,255,255},{0,255,255,255},{0,252,255,255},{0,240,255,255},{0,192,255,255},{0,128,255,255},{0,0,254,255},{0,0,254,255},{0,0,248,255},{0,0,248,255},{0,0,224,255},{0,0,224,255},{0,0,192,255},{0,0,192,255},{0,0,128,255},{0,0,128,255}},{{0,0,248,255},{0,192,248,255},{128,255,255,255},{255,255,255,255},{254,255,255,255},{224,255,255,255},{0,255,255,255},{0,252,255,255},{0,224,255,255},{0,128,255,255},{0,0,254,255},{0,0,254,255},{0,0,248,255},{0,0,248,255},{0,0,192,255},{0,0,192,255},{0,0,0,127},{0,0,0,127},{0,0,0,254},{0,0,0,254},{0,0,128,255},{0,0,128,255},{0,0,240,255},{0,0,240,255}}} , {{{255,255,255,7},{255,15,255,7},{255,63,0,0},{255,255,0,0},{255,255,1,0},{255,255,1,0},{255,255,1,0},{255,15,1,0},{255,63,0,0},{255,255,0,0},{255,255,3,0},{255,255,3,0},{255,255,31,0},{255,255,31,0},{255,253,255,0},{255,249,255,0},{255,249,255,3},{255,240,255,3},{127,224,255,7},{63,192,255,7},{63,128,255,15},{31,0,255,15},{15,0,252,31},{15,0,252,31}},{{7,0,240,31},{7,0,240,31},{3,0,0,15},{3,0,0,15},{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{3,0,0,0},{3,0,0,0},{7,0,0,0},{7,0,0,0},{7,0,0,0},{15,192,3,0},{15,224,3,0},{31,240,31,0},{31,248,31,0},{63,248,31,0},{127,252,31,0}},{{127,252,63,0},{255,252,63,0},{255,252,31,0},{255,252,31,0},{255,253,3,0},{255,255,3,0},{255,255,255,7},{255,255,255,7},{255,255,255,31},{255,255,255,31},{255,255,255,63},{255,255,255,63},{255,255,255,63},{255,255,255,63},{255,255,255,63},{255,255,255,63},{255,255,255,3},{255,3,255,3},{255,127,0,0},{255,255,0,0},{255,255,7,0},{255,255,7,0},{255,255,63,0},{255,255,63,0}},{{255,255,255,1},{255,255,255,1},{255,255,255,3},{255,255,255,3},{255,255,255,15},{255,255,255,15},{127,255,255,31},{63,254,255,31},{63,254,251,31},{31,254,251,31},{31,254,199,31},{15,252,199,31},{15,252,15,14},{7,248,15,14},{3,240,15,0},{3,224,15,0},{1,192,15,0},{1,128,15,0},{1,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}},{{0,0,0,0},{1,0,0,0},{1,0,0,0},{1,0,0,0},{3,0,0,0},{3,0,0,0},{7,0,0,0},{7,0,0,0},{15,0,0,0},{15,0,0,0},{31,0,0,0},{31,0,0,0},{63,0,252,3},{127,0,252,3},{255,192,255,7},{255,240,255,7},{255,249,255,31},{255,251,255,31},{255,255,255,31},{255,255,255,31},{255,255,255,31},{255,255,255,31},{255,255,255,31},{255,255,255,31}}} }; void setup(){ pinMode(latchPin, OUTPUT); pinMode(clockPin, OUTPUT); for(byte z = 0; z < numGroup; z++){ pinMode(dataPin[z], OUTPUT); } attachInterrupt(1, lap, RISING); //interupt for hall switch for(byte i = 0; i < numGroup; i++){ //Create a 5x5 array for blade positions based on which blade is in which area of the circle for(byte n = 0; n < numGroup; n++){ blade[i][n] = i + n; if (blade[i][n] >= numGroup) blade[i][n] = blade[i][n] - numGroup; } } } void loop(){ for(byte angle = 0; angle < numAngle; angle++){ if(RotaionCnt >= (400)){ //images switch every 100 rotations RotaionCnt = 0; image = 0; } else if (RotaionCnt >= (300)) image = 3; else if (RotaionCnt >= (200)) image = 2; else if (RotaionCnt >= (100)) image = 1; else image = 0; if (group >=numGroup) //after looping 5 times, once for each group of 24 angles, reset the base blade back to the begining group group = 0; digitalWrite(latchPin, 0); for(byte i = 0; i