งานในชั้นเรียนที่ 7 Keypad แสดงผลที่ LED 7-Segment
CODE1
#include "LedControl.h"
#include "Keypad.h"
char keys[4] [4]={
{'7','8','9','A'},
{'4','5','6','B'},
{'1','2','3','C'},
{'E','0','F','D'}};
byte rowPins[] = {7,6,5,4};
byte colPins[] = {3,2,1,0};
Keypad keypad = Keypad(makeKeymap(keys),
rowPins,colPins,4,4);
LedControl lc=LedControl(10,8,9,1);
void setup()
{
lc.shutdown(0,false);
lc.setIntensity(0,5);
lc.clearDisplay(0);
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
lc.setChar(0,0,key,false);
}
}
CODE2
#include "LedControl.h"
#include "Keypad.h"
char keys[4] [4]={
{'7','8','9','A'},
{'4','5','6','B'},
{'1','2','3','C'},
{'E','0','F','D'}};
byte rowPins[] = {7,6,5,4}; //แนวตั้ง
byte colPins[] = {3,2,1,0}; //แนวนอน
Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,4,4);
LedControl lc=LedControl(10,8,9,1);
int m=7;
void setup()
{
lc.shutdown(0,false);
lc.setIntensity(0,5);
lc.clearDisplay(0);
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
if(m==7)
lc.clearDisplay(0);
lc.setChar(0,m,key,false);
m=m-1;
if(m < 0)
m = 7;
}
}
CODE3
#include "LedControl.h"
#include "Keypad.h"
char keys[4][4]={
{'7','8','9','A'},
{'4','5','6','B'},
{'1','2','3','C'},
{'E','0','F','D'}};
byte rowPins[] = {7,6,5,4};
byte colPins[] = {3,2,1,0};
Keypad keypad = Keypad(makeKeymap(keys),
rowPins,colPins,4,4);
LedControl lc=LedControl(10,8,9,1);
void setup()
{
lc.shutdown(0,false);
lc.setIntensity(0,5);
lc.clearDisplay(0);
}
void loop()
{
char key = keypad.getKey();
if (key != NO_KEY)
{
lc.setChar(0,0,key,false);
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น