|
楼主 |
发表于 2016-8-24 20:34
|
显示全部楼层
附上代码:
/*define pin*/
#define SCLR_PIN 2
#define SI_PIN 3
#define SCK_PIN 4
#define RCK_PIN 5
#define OE_PIN 6
/*define the map of value 0-9*/
#define NUM_VAL 11
int val[NUM_VAL]= {
0xDE,//0
0x06,//1
0xEC,//2
0xAE,//3
0x36,//4
0xBA,//5
0xFA,//6
0x0E,//7
0xFE,//8
0xBE,//9
0x01,//dot
};
/*define the function of display val*/
void disVal(int val);
void setup() {
// put your setup code here, to run once:
pinMode(SCLR_PIN, OUTPUT);
pinMode(SI_PIN, OUTPUT);
pinMode(SCK_PIN, OUTPUT);
pinMode(RCK_PIN, OUTPUT);
pinMode(OE_PIN, OUTPUT);
return;
}
void loop() {
digitalWrite(OE_PIN, LOW);
// put your main code here, to run repeatedly:
for(int i = 0; i < NUM_VAL; i++ )
{
disVal(val[i]);
//disVal(0xDE);
delay(1000);
}
return;
}
void disVal(int val)
{
//set RCK to Low
digitalWrite(RCK_PIN, LOW);
//clear SHIFT Story
digitalWrite(SCLR_PIN, LOW);
digitalWrite(SCLR_PIN, HIGH);
//set the val to SHIFT Story
shiftOut(SI_PIN, SCK_PIN, MSBFIRST, val);
//set RCK to HIGH
digitalWrite(RCK_PIN, HIGH);
return;
}
|
|