Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Better Shift Code for Gluestick 7 Segment

By: Azdle on Aug 25th, 2011  |  syntax: C  |  size: 0.58 KB  |  views: 295  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // hot glue seven segment display test
  2.  
  3. // define pins used
  4. #define dataPin 2
  5. #define latchPin 3
  6. #define clockPin 4
  7.  
  8. // define light patterns
  9. byte digits[] = {B01100000,
  10.                 B11011010,
  11.                 B11110010,
  12.                 B11100100,
  13.                 B10110110,
  14.                 B10111110,
  15.                 B01100010,
  16.                 B11111110,
  17.                 B11100110,
  18.                 B01111110};
  19.  
  20. void setup()
  21. {
  22.         pinMode(dataPin, OUTPUT);
  23.         pinMode(latchPin, OUTPUT);
  24.         pinMode(clockPin, OUTPUT);
  25. }
  26.  
  27. void loop()
  28. {
  29.         for(int i = 0; i <= 9; i++){
  30.                 digitalWrite(latchPin, LOW);
  31.                 shiftOut(dataPin, clockPin, MSBFIRST, one);
  32.                 digitalWrite(latchPin, HIGH);
  33.                 delay(2000);
  34.         }
  35. }