Advertisement
ZRE0412

Arduino-HomeWork-??-7seg-count_down-ver2

May 20th, 2021 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char TAB[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D,
  2.               0x7D, 0x27, 0x7F, 0x67, 0x77, 0x7C,
  3.               0x39, 0x5E, 0x79, 0x71};
  4.  
  5. int val = 0, orgin;
  6.  
  7. void setup() {
  8.   // put your setup code here, to run once:
  9.   DDRD |= 0b11111111;
  10.   PORTD = 0x00;
  11.   val = PINB;
  12.   orgin = val;
  13. }
  14.  
  15. void loop() {
  16.   // put your main code here, to run repeatedly:
  17.   if(val!=0){
  18.     PORTD = TAB[val--];
  19.     delay(1000);
  20.   }
  21.   else{
  22.     for(int i=0;i<3;i++){
  23.       PORTD = TAB[val];
  24.       delay(300);
  25.       PORTD = 0x00;
  26.       delay(300);
  27.     }
  28.     val = orgin;
  29.     delay(300);
  30.   }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement