Last active
July 14, 2016 01:39
-
-
Save hsgw/d065d1c7da1eb7bb47c3d1c2b65a9d5f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void hSync(byte a[][8]){ | |
for(int i = 0;i < 8;i++){//階層ループ | |
for(int j = 0;j < 8;j++){//列ループ | |
for(int k = 0;k < 8;k++){ | |
// このLEDCUBEではシフトレジスタのclk(SCK)とratch(RCK)を共有しています。 | |
// そのため、8つのシフトレジスタのser(SI)にそれぞれデータをセットして | |
digitalWrite(ser[k],bitRead(a[i][k],j)); | |
} | |
digitalWrite(clk,1); | |
delayMicroseconds(10); | |
digitalWrite(clk,0); | |
// clkを上げ下げすることで1行8ドット分のデータを一気にシフトレジスタに転送しています。 | |
}//列ループend | |
if(i == 0){//前のレイヤーoff | |
digitalWrite(layer[7],0); | |
}else{ | |
digitalWrite(layer[i-1],0); | |
} | |
//シフトレジスタのratchを上げ下げしてシフトレジスタの出力にデータを反映させています。 | |
digitalWrite(ratch,1);//シフトレジスタratch | |
delayMicroseconds(10); | |
digitalWrite(ratch,0); | |
digitalWrite(layer[i],1);//レイヤーon | |
delayMicroseconds(800); | |
}//階層ループend | |
delayMicroseconds(800); | |
digitalWrite(layer[7],0);//layer[7]をoff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment