Você está na página 1de 1

// PROGRAMA 10

// ENVIO DE DATOS POR EL PUERTO PARALELO


#include <stdio.h>
#include <conio.h>
#include <dos.h>
void binario ();
char k;
void main ()
{
_setcursortype (_NOCURSOR);
clrscr ();
textbackground (BLACK); textcolor (WHITE);
gotoxy (30,6); cprintf (" Tecla");
textbackground (BLACK); textcolor (GREEN);
gotoxy (20, 8); cprintf ("");
gotoxy (20, 9); cprintf (" ");
gotoxy (20, 10); cprintf ("");
do {
k=getch();
binario ();
textbackground (BLACK); textcolor (WHITE);
gotoxy (30,6); cprintf (" Tecla %c\n", k);
outportb (0x378, k);
}
while (k!=27);
}
void binario ()
{
int x, y, bin [9], cont;
y=k;
for (cont=1; cont<9; cont++){
x=y/2;
bin [9-cont]=y-2*x;
y=x;
}
/*
gotoxy (50,6);
for (cont=1; cont<9; cont++){
textcolor (WHITE); cprintf ("%d", bin [cont]);
}
*/
for (cont=1; cont<9; cont++){
if (bin [cont]==1){
textcolor (RED);
gotoxy (22+4*cont-4,9); cprintf ("");
}
else {
textcolor (BLACK);
gotoxy (22+4*cont-4,9); cprintf ("");
}
}
}

Você também pode gostar