Created
August 6, 2016 08:12
-
-
Save aminosan/26d88e530a6d9eac684192de1f4a0711 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
/* | |
* クロック:1 | |
* ラッチ:3 | |
* データ(赤):5 | |
* データ(緑):7 | |
* イネーブル:9 | |
* データ(青):11 | |
*/ | |
// 0,1ピンは使わず、2ピンからはじめる | |
#define SCLK 2 // クロック | |
#define SRAT 4 // ラッチ | |
#define SIN_R 6 // データ(赤) | |
#define SIN_G 8 // データ(緑) | |
#define ENABLE 10 // ENABLE | |
#define SIN_B 12 // データ(青) | |
int led = 1; | |
int i = 0; | |
void setup() { | |
pinMode(SCLK, OUTPUT); | |
pinMode(SRAT, OUTPUT); | |
pinMode(SIN_R, OUTPUT); | |
pinMode(SIN_G, OUTPUT); | |
pinMode(SIN_B, OUTPUT); | |
pinMode(ENABLE, OUTPUT); | |
} | |
void loop() { | |
while(1) { | |
digitalWrite(ENABLE, HIGH); // イネーブルHI | |
digitalWrite(SRAT, LOW); // ラッチLOW | |
// R | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 8 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 7 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 6 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 5 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 4 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 3 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 2 | |
shiftOut(SIN_R, SCLK, MSBFIRST, 0xff); // SEG 1 | |
// G | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 8 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 7 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 6 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 5 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 4 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 3 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 2 | |
shiftOut(SIN_G, SCLK, MSBFIRST, 0xff); // SEG 1 | |
// B | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 8 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 7 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 6 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 5 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 4 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 3 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 2 | |
shiftOut(SIN_B, SCLK, MSBFIRST, 0xff); // SEG 1 | |
digitalWrite(SRAT, HIGH); // ラッチHI | |
digitalWrite(SRAT, LOW); // ラッチLOW | |
digitalWrite(ENABLE, LOW); // イネーブルHI | |
delay(1); | |
// delayMicroseconds(30); // like the PWM | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MFTで会場で購入した者です。無事点灯できましたありがとうございました。