Advertisement
jmyean

Shift Register Circuit with LED Digit

May 7th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Jung Min Yean
  3.  * Learning How to Use a Shift Register
  4.  * Digit LED
  5.  * 05/02/19
  6.  */
  7.  
  8.  const int Data = 8; // The output
  9.  const int Latch = 9;
  10.  const int Clock = 10; // Goes around the Shift Register
  11.  int sequenceog[] = {0,1,2,4,8,16,32,64,128};
  12.  int sequence1[] = {126,18,188,182,210,230,238,50,254,246};
  13.  
  14.  
  15. void setup()
  16. {
  17.   pinMode(Data, OUTPUT);
  18.   pinMode(Latch, OUTPUT);
  19.   pinMode(Clock, OUTPUT);
  20. }
  21.  
  22.  
  23. void loop()
  24. {
  25.   for(int i = 0; i < 10; i++)
  26.   {
  27.     digitalWrite(Latch, LOW);
  28.     shiftOut(Data, Clock, MSBFIRST, sequence1[i]);
  29.     delay(1000);
  30.     digitalWrite(Latch, HIGH);
  31.     delay(1000);
  32.   }
  33. }
  34.  
  35. // middle LED = B00000001
  36. // top left = B00000010
  37. // top = B00000100
  38. // top right = B00001000
  39. // bottom left = B00010000
  40. // bottom = B00100000
  41. // bottom right = B01000000
  42. // period = B10000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement