Last active
December 19, 2015 19:49
-
-
Save coderaven/6009337 to your computer and use it in GitHub Desktop.
Interfacing 7 Segment with Parallel Port (Increment and Decrement)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <dos.h> | |
#define OUT 0x378 | |
#define IN 0x379 | |
int d1[10] = {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09}; | |
int d2[10] = {0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,0x80,0x90}; | |
void display(int n){ | |
outportb(OUT,d2[n/10] | d1[n%10]); | |
delay(100000); | |
} | |
int main(){ | |
int n = 0, p; | |
display(0); | |
while(1){ | |
p = inportb(IN); | |
if (!(p & 0x10)){ | |
n++; if (n > 99) n = 0; | |
display(n); | |
} else if (!(p & 0x20)){ | |
n--; if (n < 0) n = 99; | |
display(n); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment