osama222_1@hotmail.com
Parallel Port
A parallel port is a type of interface found on computers (personal and otherwise) for connecting various peripherals. It is also known as a printer port or Centronics port. The IEEE 1284 standard defines the bi-directional version of the port।
Port Address
Traditionally IBM PC systems have allocated their first three parallel ports according to the configuration in the table below.
LPT1
LPT2
LPT3
1) Compatibility Mode 2) Nibble Mode 3) Byte Mode 4) EPP 5) ECP
The programs, circuits and other information found in this tutorial are compatible to almost all types of parallel ports and can be used without any problems (Not tested, just because of confidence ! ). More information on parallel port operating modes can be found
HardwareThe pin outs of DB25 connector is shown in the picture below
The lines in DB25 connector are divided in to three groups, they are
1) Data lines (data bus) 2) Control lines 3) Status lines
Code
Note: i just made a class of parallel_port in which i define the function so if you want to run the program then you have to made a class it is very simple just go to project menu then add class from there and the name of the class will be parallel_port and the class code will be given below just paste it and most important thing you must have to download inpout32.dll if you not find it then send me email i will send you i hope you enjyou it.....
Class Code
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace Controlling_home_appliance_SMS
{
class parallel_port_interfacing
{
//Call OutPut function from DLL file.
[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);
//Call Input functionfrom DLL file
[DllImport("inpout32.dll", EntryPoint = "Inp32")]
public static extern void Input(int adress);
}
class parallel_port
{
public void reset()
{
//heneral addresss are 888 and 632
parallel_port_interfacing.Output(888, 0);
}
public void light1()
{
parallel_port_interfacing.Output(888, 1);
}
public void light2()
{
parallel_port_interfacing.Output(888, 2);
}
public void light3()
{
parallel_port_interfacing.Output(888, 4);
}
public void light4()
{
parallel_port_interfacing.Output(888, 8);
}
public void light5()
{
parallel_port_interfacing.Output(888, 16);
}
public void all()
{
parallel_port_interfacing.Output(888, 31);
}
}
}
Main Form Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Controlling_home_appliance_SMS
{
public partial class Form1 : Form
{
parallel_port led = new parallel_port();
public Form1()
{
InitializeComponent();
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
led.light1();
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
led.light2();
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
led.light3();
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
led.light4();
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (textBox1.Text == "light1")
{
led.light1();
label4.Text="light "+1+" On";
}
else if (textBox1.Text == "light2")
{
led.light2();
label4.Text = "light " + 2 + " On";
}
else if (textBox1.Text == "light3")
{
led.light3();
label4.Text = "light " + 3 + " On";
}
else if (textBox1.Text == "light4")
{
led.light4();
label4.Text = "light " + 4 + " On";
}
else if (textBox1.Text == "light5")
{
led.light5();
label4.Text = "light " + 5 + " On";
}
else if (textBox1.Text == "all")
{
led.all();
label4.Text = "all lights On";
}
else
{
led.reset();
label4.Text = "";
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
}
private void exitToolStripMenuItem_Click_1(object sender, EventArgs e)
{
Application.Exit();
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
}
private void radioButton5_CheckedChanged(object sender, EventArgs e)
{
led.light5();
}
private void radioButton6_CheckedChanged(object sender, EventArgs e)
{
led.all();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}