Last active
September 15, 2019 20:48
-
-
Save brunopk/6b390430e51bb648cb608083f917955f to your computer and use it in GitHub Desktop.
Code to control LPT port with C (based on https://www.howtoforge.com/tutorial/accessing-parallel-ports-on-linux/)
This file contains hidden or 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 <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/io.h> | |
#define base 0x378 /* parallel port base address */ | |
int main(){ | |
int y; | |
if (ioperm(base,1,1)){ | |
fprintf(stderr, "Access denied to %x\n", base); | |
exit(1); | |
} | |
/* Send 00000000 to parallel port to clear all bits */ | |
outb(0x00, base); | |
/* Send 00001111 to parallel port */ | |
outb(0xF0, base); | |
scanf("%d", &y); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment