So, zumindest die Ausgänge ( auf dem Bild die Pins D0 bis D7) kannste jetzt testen, wenn du von denen ne LED mit passendem Vorwiederstand (470 Ohm sollten fast schen zu viel sein) von denen mit der Katode zu GND anschließt.
Code:
//------------------------------------------------------------------------------
//Autor : AlKi
//Programm: Ansprechen der Ausgänge des Parallel Port´s
//im 2-Sekunden-Takt
//------------------------------------------------------------------------------
#include <conio.h>
#include <iostream.h>
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
//==============================================================================
typedef short (_stdcall *inpfuncPtr)(short);
typedef void (_stdcall *oupfuncPtr)(short, short);
extern inpfuncPtr inp32fp;
extern oupfuncPtr oup32fp;
#define PPORT_BASE 0x378
short Inp32 (short);
void Out32 (short, short);
//------------------------------------------------------------------------------
short Inp32 (short Port)
{
return (inp32fp)(Port);
}
void Out32 (short Port, short Data)
{
(oup32fp)(Port, Data);
}
//==============================================================================
inpfuncPtr inp32fp;
oupfuncPtr oup32fp;
short Daten=0;
void display (short);
void display (short input)
{
Daten=Inp32(PPORT_BASE);
Out32(PPORT_BASE, input);
}
//------------------------------------------------------------------------------
int main()
{
HINSTANCE hLib;
int INF=0, i=0, x=0, y=0, z=0, a=0, b=0, c=0, Zeit=2000; //Wartezeit in Millisekunden
//-----------------------Bibliothek wird geladen-------------------------------
hLib=LoadLibrary("inpout32.dll");
if (hLib==NULL)
{
cout<<"inpout32.dll nicht vorhanden"<<endl;
cout<<" PROGRAMM WIRD BEENDET "<<endl;
exit(0);
}
//------------------------Befehl wird geladen----------------------------------
inp32fp=(inpfuncPtr) GetProcAddress(hLib, "Inp32");
if (inp32fp==NULL)
{
exit (0);
}
//------------------------Befehl wird geladen----------------------------------
oup32fp=(oupfuncPtr) GetProcAddress(hLib, "Out32");
if (oup32fp==NULL)
{
exit (0);
}
//-----------------------------------------------------------------------------
display(0); //alles wird auf 0 gesetzt
//-----------------------------Hauptteil----------------------------------------
cout<<" Port wird getestet "<<endl;
//------------------------- X-Achse -------------------------------
display(1); // pin D0 an
Sleep(Zeit);
display(0); // alle Pins aus
Sleep(Zeit);
display(2); // Pin D1 an
Sleep(Zeit);
display(0); // alle Pins aus
Sleep(Zeit);
display(4); // Pin D2 an
Sleep(Zeit);
display(0); // alle Pins aus
Sleep(Zeit);
display(8); // Pin D3 an
Sleep(Zeit);
display(0); // alle Pins aus
Sleep(Zeit);
display(16); // Pin D4 an
Sleep(Zeit);
display(0); // alle Pins aus
Sleep(Zeit);
display(32); // Pin D5 an
Sleep(Zeit);
display(0); // alle Pins aus
Sleep(Zeit);
display(64); // Pin D6 an
display(0); // alle Pins aus
Sleep(Zeit);
display(128); // Pin D7 an
Sleep(Zeit);
display(0); //alles wird auf 0 gesetzt
FreeLibrary("inpout32.dll");
getch();
return 0;
}
Devcpp gibts kostenlos als compiler, probiers damit.
Viel Glück
EDIT: wenn bei dir nix anspricht, also keine Software was mit dem Druckerport machen kann, liegts vlt daran, dass du Windows NT/XP hast, da wird der zugriff auf die Ports verweigert.
Lösen kannste das problem dann mit nem Programm namens "Openport" oder so ähnlich. Das Programm lässt die anderen Programme dann auf die Ports zugreifen.
Lesezeichen