arduinoでqyf-tm1638ボード

#概要

arduinoでqyf-tm1638ボード使ってみた。
key拾ってみた。

#写真

![CIMG2965.JPG](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/c094b983-ff38-fd43-89ac-4f42397a906c.jpeg)


#サンプルコード

```
#define stb 	10
#define clk 	9
#define dio 	8

void printn(uint8_t v) {
	if (v > 9) return;
	uint8_t t;
	uint8_t a[] = {1, 0, 1, 1, 0, 1, 0, 1, 1, 1};
	uint8_t b[] = {1, 1, 1, 1, 1, 0, 0, 1, 1, 1};
	uint8_t c[] = {1, 1, 0, 1, 1, 1, 1, 1, 1, 1};
	uint8_t d[] = {1, 0, 1, 1, 0, 1, 1, 0, 1, 0};
	uint8_t e[] = {1, 0, 1, 0, 0, 0, 1, 0, 1, 0};
	uint8_t f[] = {0, 0, 0, 0, 1, 1, 1, 0, 1, 1};
	uint8_t g[] = {0, 0, 1, 1, 1, 1, 1, 0, 1, 1};
	uint8_t h[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0x40);
	digitalWrite(stb, HIGH);

	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0xc0);
	t = a[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = b[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = c[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = d[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = e[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = f[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = g[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	t = h[v] << 4;
	shiftOut(dio, clk, LSBFIRST, t);
	shiftOut(dio, clk, LSBFIRST, 0x01);
	digitalWrite(stb, HIGH);
}
void setup() {
	Serial.begin(9600);
	pinMode(stb, OUTPUT);
	pinMode(clk, OUTPUT);
	pinMode(dio, OUTPUT);

	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0x88);
	digitalWrite(stb, HIGH);

	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0x40);
	digitalWrite(stb, HIGH);

	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0xc0);

	shiftOut(dio, clk, LSBFIRST, 0x10);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x10);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x10);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x10);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x10);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x10);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x00);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	shiftOut(dio, clk, LSBFIRST, 0x00);
	shiftOut(dio, clk, LSBFIRST, 0x01);

	digitalWrite(stb, HIGH);

	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0x88);
	digitalWrite(stb, HIGH);
	Serial.print("ok");
}

void loop() {
	uint8_t v;
	uint8_t btn = 0;
	digitalWrite(stb, LOW);
	shiftOut(dio, clk, LSBFIRST, 0x42);
	pinMode(dio, INPUT);
	v = shiftIn(dio, clk, LSBFIRST);
	if (v == 0x02)
	{
		btn = 1;
	}
	else if (v == 0x04)
	{
		btn = 2;
	}
	else if (v == 0x20)
	{
		btn = 3;
	}
	else if (v == 0x40)
	{
		btn = 4;
	}
	v = shiftIn(dio, clk, LSBFIRST);
	if (v == 0x02)
	{
		btn = 5;
	}
	else if (v == 0x04)
	{
		btn = 6;
	}
	else if (v == 0x20)
	{
		btn = 7;
	}
	else if (v == 0x40)
	{
		btn = 8;
	}
	v = shiftIn(dio, clk, LSBFIRST);
	if (v == 0x02)
	{
		btn = 9;
	}
	else if (v == 0x04)
	{
		btn = 10;
	}
	else if (v == 0x20)
	{
		btn = 11;
	}
	else if (v == 0x40)
	{
		btn = 12;
	}
	v = shiftIn(dio, clk, LSBFIRST);
	if (v == 0x02)
	{
		btn = 13;
	}
	else if (v == 0x04)
	{
		btn = 14;
	}
	else if (v == 0x20)
	{
		btn = 15;
	}
	else if (v == 0x40)
	{
		btn = 16;
	}
	pinMode(dio, OUTPUT);
	digitalWrite(stb, HIGH);
	if (btn > 0) 
	{
	  printn(btn);
	  Serial.println(btn);
	}
	delay(500);
}





```

以上。