arduino의 qyf-tm1638 보드
4347 단어 Arduino
개요
arduino에서 qyf-tm1638 보드를 사용해 보았습니다.
key 주워 보았다.
사진
샘플 코드
#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);
}
이상.
Reference
이 문제에 관하여(arduino의 qyf-tm1638 보드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ohisama@github/items/57a742f44d48afecdd90
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
샘플 코드
#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);
}
이상.
Reference
이 문제에 관하여(arduino의 qyf-tm1638 보드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/ohisama@github/items/57a742f44d48afecdd90
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
#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);
}
Reference
이 문제에 관하여(arduino의 qyf-tm1638 보드), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/ohisama@github/items/57a742f44d48afecdd90텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)