Advertisement
tonyoo

Untitled

Oct 20th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.14 KB | None | 0 0
  1. /*
  2.  
  3. */
  4.  
  5. // set up a variable for the switch case
  6. byte var = 1;  setup and per loads 1 because I never wanted to be equal to zero
  7.  
  8. // the setup function runs once when you press reset or power the board
  9. void setup() {
  10.  
  11.  //next part is to set up and  declare all the pins and tell you what they're attached to  
  12.   pinMode(13, OUTPUT);  // clk pin
  13.   pinMode(11, OUTPUT);  // data pin
  14.   pinMode(2, OUTPUT);  // on the negative cathode of 16 sagmint  one
  15.   pinMode(3, OUTPUT);  //  on the negative cathode of 16 sagmint  two
  16.   pinMode(4, OUTPUT); //  on the negative cathode of 16 sagmint  3
  17.   pinMode(5, OUTPUT); //  on the negative cathode of 16 sagmint  4
  18.   pinMode(6, OUTPUT); //  on the negative cathode of 16 sagmint  5
  19.   pinMode(7, OUTPUT); // 16 sagmint 6
  20.  
  21.   // this is to set the clk to low if you don't do this it takes a shit
  22.   digitalWrite(13, LOW);  // this has to be here for the 74164
  23. }
  24.  
  25. // the loop function runs over and over again forever
  26. void loop() {
  27.  
  28. // this parts to run the switch case
  29. var++;
  30. if (var == 7){
  31.   var = 1;
  32.   }
  33.  
  34. switch (var) {
  35.     case 1:  // this loads the 47164s with data
  36.      shiftOut(11, 13, LSBFIRST, B11110000);
  37.      shiftOut(11, 13, LSBFIRST, B00000000);
  38.      // this sets wich 16 sag to use
  39.      digitalWrite(2, HIGH);
  40.      digitalWrite(3, HIGH);
  41.      digitalWrite(4, HIGH);
  42.      digitalWrite(5, HIGH);
  43.      digitalWrite(6, HIGH);
  44.      digitalWrite(7, LOW);
  45.        
  46.       break;
  47.     case 2:
  48.  shiftOut(11, 13, LSBFIRST, B11111111);
  49.  shiftOut(11, 13, LSBFIRST, B00000000);
  50.  
  51.      digitalWrite(2, HIGH);
  52.      digitalWrite(3, HIGH);
  53.      digitalWrite(4, HIGH);
  54.      digitalWrite(5, HIGH);
  55.      digitalWrite(6, LOW);
  56.      digitalWrite(7, HIGH);
  57.       break;
  58.           case 3:
  59.  shiftOut(11, 13, LSBFIRST, B00001100);
  60.  shiftOut(11, 13, LSBFIRST, B00010001);
  61.      digitalWrite(2, HIGH);
  62.      digitalWrite(3, HIGH);
  63.      digitalWrite(4, HIGH);
  64.      digitalWrite(5, LOW);
  65.      digitalWrite(6, HIGH);
  66.      digitalWrite(7, HIGH);
  67.       break;
  68.           case 4:
  69.  shiftOut(11, 13, LSBFIRST, B11100001);
  70.  shiftOut(11, 13, LSBFIRST, B10000000);
  71.      digitalWrite(2, HIGH);
  72.      digitalWrite(3, HIGH);
  73.      digitalWrite(4, LOW);
  74.      digitalWrite(5, HIGH);
  75.      digitalWrite(6, HIGH);
  76.      digitalWrite(7, HIGH);
  77.       break;
  78.           case 5:
  79.  shiftOut(11, 13, LSBFIRST, B00000000);
  80.  shiftOut(11, 13, LSBFIRST, B00000000);
  81.      digitalWrite(2, HIGH);
  82.      digitalWrite(3, LOW);
  83.      digitalWrite(4, HIGH);
  84.      digitalWrite(5, HIGH);
  85.      digitalWrite(6, HIGH);
  86.      digitalWrite(7, HIGH);
  87.      
  88.       break;
  89.           case 6:
  90.      shiftOut(11, 13, LSBFIRST, B11111100);
  91.      shiftOut(11, 13, LSBFIRST, B00000000);
  92.      digitalWrite(2, LOW);
  93.      digitalWrite(3, HIGH);
  94.      digitalWrite(4, HIGH);
  95.      digitalWrite(5, HIGH);
  96.      digitalWrite(6, HIGH);
  97.      digitalWrite(7, HIGH);
  98.       break;
  99.  
  100.     default:
  101.  
  102.     break;
  103. }
  104.  
  105.      digitalWrite(2, HIGH);
  106.      digitalWrite(3, HIGH);
  107.      digitalWrite(4, HIGH);
  108.      digitalWrite(5, HIGH);
  109.      digitalWrite(6, HIGH);
  110.      digitalWrite(7, HIGH);
  111.  shiftOut(11, 13, LSBFIRST, B00000000);
  112.  shiftOut(11, 13, LSBFIRST, B00000000);
  113.  
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement