#define CLK 3 #define DAT 4 #define WAIT 5 void setup() { pinMode(CLK, OUTPUT); pinMode(DAT, OUTPUT); digitalWrite(CLK, HIGH); delay(200); } void loop() { for(int i=0; i<256; i++) { sendByte(i); delay(200); } } void sendByte(uint8_t bt) { digitalWrite(CLK, LOW); //スタートビット delay(WAIT); digitalWrite(CLK, HIGH); delay(WAIT); for(int n = 0; n < 8; n++) { digitalWrite(DAT, (bt >> n) & 1); delay(WAIT); digitalWrite(CLK, LOW); delay(WAIT); digitalWrite(CLK, HIGH); } }