Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 範例5
- 每隔1秒鐘,在七段顯示器上顯示0~9,正數,依此循環。
- 範例6
- 每隔1秒鐘,在七段顯示器上顯示9~0,倒數,依此循環。
- 硬體接線a接0 b接1 c接2...以此類推
- */
- void setup()
- {
- for(int i=0;i<=7;i++) //將0~7腳設定為輸出
- pinMode(i,OUTPUT);
- }
- int LED[]=
- {
- B0111111,//0
- B0000110,//1
- B1011011,//2
- B1001111,//3
- B1100110,//4
- B1101101,//5
- B1111101,//6
- B0100111,//7
- B1111111,//8
- B1100111 //9
- };
- void loop()
- {
- for(int i=9;i>=0;i--) //若要由0數到9則本行改為 for(int i=0;i<=9;i++)
- {
- PORTD=LED[i];
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement