Advertisement
uas_arduino

Seven Segment LUT Counter

Apr 19th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. byte outputPins[] = {3,4,5,6,7,8,9};
  2. byte currentValue = 0;
  3.                      //ABCDEFG0
  4. byte lookupTable[] = {BXXXXXXX0, //0
  5.                       BXXXXXXX0, //1
  6.                       BXXXXXXX0, //2
  7.                       BXXXXXXX0, //3
  8.                       BXXXXXXX0, //4
  9.                       BXXXXXXX0, //5
  10.                       BXXXXXXX0, //6
  11.                       BXXXXXXX0, //7
  12.                       BXXXXXXX0, //8
  13.                       BXXXXXXX0}; //9
  14.  
  15. void setup(){
  16.     for(byte a = 0; a < 7; a++){
  17.         pinMode(outputPins[a],OUTPUT);
  18.     }
  19. }
  20.  
  21. void loop(){
  22.     if(currentValue == 11){
  23.         currentValue = 0;
  24.     }
  25.     for(byte a = 0; a < 7;a++){
  26.         if(lookupTable[currentValue] & (0x80 >> a)){
  27.             digitalWrite(outputPins[a],HIGH);
  28.         }else{
  29.             digitalWrite(outputPins[a],LOW);
  30.         }
  31.     }
  32.  
  33.     delay(1000);
  34.     currentValue++;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement