Skip to content

Instantly share code, notes, and snippets.

@aminosan
Created August 6, 2016 08:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aminosan/26d88e530a6d9eac684192de1f4a0711 to your computer and use it in GitHub Desktop.
Save aminosan/26d88e530a6d9eac684192de1f4a0711 to your computer and use it in GitHub Desktop.
/*
* クロック: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
}
}
@moxuse
Copy link

moxuse commented Aug 30, 2016

MFTで会場で購入した者です。無事点灯できましたありがとうございました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment