Advertisement
uas_arduino

Seven Segment LUT Push Button

Apr 19th, 2013
65
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. volatile 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 increment(){
  16.     currentValue++;
  17. }
  18.  
  19. void setup(){
  20.     for(byte a = 0; a < 7; a++){
  21.         pinMode(outputPins[a],OUTPUT);
  22.     }
  23.     attachInterrupt(0, increment, RISING);
  24. }
  25.  
  26. void loop(){
  27.     if(currentValue == 11){
  28.         currentValue = 0;
  29.     }
  30.     for(byte a = 0; a < 7;a++){
  31.         if(lookupTable[currentValue] & (0x80 >> a)){
  32.             digitalWrite(outputPins[a],HIGH);
  33.         }else{
  34.             digitalWrite(outputPins[a],LOW);
  35.         }
  36.     }
  37.  
  38.     //delay(1000);
  39.     //currentValue++;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement