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.

Parallel port programming in c#(to control a led light)

Status
Not open for further replies.

Malli510

Newbie level 3
Joined
Jul 1, 2012
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,307
As i want control a led light

i attached it's +ve to D-0 and negative to ground pin in parallel port

the led glows when system boots up
and i have written my program in c#.net
as below



Code C# - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Runtime.InteropServices;
 
public class PortAccess
{
 
    [DllImport("inpoutx64.dll", EntryPoint = "Out32")]
    public static extern void Output(int adress, int value);
 
    [DllImport("inpoutx64.dll", EntryPoint = "Inp32")]
    public static extern int Input(int adress);
 
}
 
and i place my inpoutx64.dll in 
C:/windows/system/
 
C:/windows/system32/
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        public static void Main(string[] args)
        {
            int address = 888;
            int value;
            PortAccess.Output(888,255);
            value = PortAccess.Input(address);
            Console.WriteLine(value);
            PortAccess.Output(888,0);
            Console.ReadLine();
 
        }
    }
}


when i run the program it shows no error and runs fine but the led is not glowing

can anyone plz help ..me
thanks in advance;
 
Last edited by a moderator:

thanks for the link but can you explain what's wrong in my code ,

it seems inpoutx64.dll is working fine but how does it link with hwinterface.sys file *(does it create's it own hwinterface.sys or do i need to download it )*

if i have hwinterface.sys file how to link it with inpoutx64.dll or do i need place it some where

https://obrazki.elektroda.pl/76_1341208219.gif
 

You need to put the driver file in your System32\Drivers folder. Make sure, if your using XP/2003 x64 Editions, to put the 64bit version there (hwinterfacedrvx64.sys) instead of the original 32bit version (hwinterface.sys)

See more **broken link removed**
 

even after placing hwinterfacex64.sys file in system32/driver/ folder the led is not glowing .... my program runs well and it shows no errors or warnings....
 

You are setting your output back to off before you are doing the console.read
try changing your main to this:

public static void Main(string[] args)
{
int address = 888;
int value;
value = PortAccess.Input(address);
Console.WriteLine(value);
//FF or 255 D0-D7 on
PortAccess.Output(888,255);
Console.ReadLine();
//00 or 0 D0-D7 off
PortAccess.Output(888,0);
Console.ReadLine();
}

As i want control a led light

i attached it's +ve to D-0 and negative to ground pin in parallel port

the led glows when system boots up
and i have written my program in c#.net
as below



Code C# - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Runtime.InteropServices;
 
public class PortAccess
{
 
    [DllImport("inpoutx64.dll", EntryPoint = "Out32")]
    public static extern void Output(int adress, int value);
 
    [DllImport("inpoutx64.dll", EntryPoint = "Inp32")]
    public static extern int Input(int adress);
 
}
 
and i place my inpoutx64.dll in 
C:/windows/system/
 
C:/windows/system32/
 
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication1
{
    class Program
    {
        public static void Main(string[] args)
        {
            int address = 888;
            int value;
            PortAccess.Output(888,255);
            value = PortAccess.Input(address);
            Console.WriteLine(value);
            PortAccess.Output(888,0);
            Console.ReadLine();
 
        }
    }
}


when i run the program it shows no error and runs fine but the led is not glowing

can anyone plz help ..me
thanks in advance;
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top