Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Dev C++ Parallel Port Interfacing Problem...

Status
Not open for further replies.

myasir786

Newbie level 6
Joined
Mar 10, 2011
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,391
The following is my Program in Dev C++ for Parallel Port Interfacing to operate the Remote of the Car. Their is an Problem that once i press the button, Car Runs continuously although i leave the button and i have to stop the car by pressing another button. Please tell me how can i alter my Program so that it stops automatically as i leave the button.

//////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <conio.h>
#include <windows.h>
#include<iostream>
using namespace std;
typedef void _stdcall (*oupfuncPtr)(short portaddr, short datum);
int main()
{
HINSTANCE hLib;
oupfuncPtr out32;

// Load the library
hLib = LoadLibrary("inpout32.dll");

//get the address of the function
out32 = (oupfuncPtr) GetProcAddress(hLib, "Out32");

//code goes here
cout<<"Parallel Port Interfacing"<<endl;
cout<<"Press 8 to forw, 2 to reverse,4 to left,6 to right,1 to forw&left and 3 to forw&right:"<<endl;
int inp;
do
{
inp=getch();
out32(0x378,0x00);
if(inp=='8')//D0 forward
{
cout<<"forward";
out32(0x378,0x01);
}
else if(inp=='2')//D1 reverse
{
cout<<"reverse";
out32(0x378,0x02);
}
else if(inp=='4')//D2 left
{
cout<<"left";
out32(0x378,0x04);
}
else if(inp=='6')//D3 right
{
cout<<"right";
out32(0x378,0x08);
}
else if(inp=='1')//D0&D2 forward&left
{
cout<<"forward and left";
out32(0x378,0x05);
}
else if(inp=='3')//D0&D3 forward&right
{
cout<<"forward and right";
out32(0x378,0x09);
}
}
while(inp=='1'||inp=='2'||inp=='3'||inp=='4'||inp=='6'||inp=='8');
system("pause");
return 0;
}
 

Instead of if use while


example: while(inp=='8')//D0 forward
{
cout<<"forward";
out32(0x378,0x01);
}
 

Thanks I'll Try That...

---------- Post added at 02:38 ---------- Previous post was at 02:32 ----------

Its Not Working Correctly it is not terminating its just continuously forwarding it is not allowing to stop.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top